-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUser.py
More file actions
86 lines (79 loc) · 3.07 KB
/
User.py
File metadata and controls
86 lines (79 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import re
import json
class User:
def __init__(self, mail, password):
self.mail = mail
self.password = password
def isMailExist(self,mail):
self.mail = mail
with open("usersData.json") as f:
readData = json.load(f)
for i in readData:
if mail == i["mail"]:
return True
return False
def isExistAccount(self,mail, password):
self.mail = mail
self.password = password
with open("usersData.json") as f:
readData = json.load(f)
for i in readData:
print(i["mail"])
print(i["password"])
while True:
if mail == i["mail"] and password == i["password"]:
return True
else:
break
return False
def saveUserToJson(self, mail, password):
self.mail = mail
self.password = password
if not self.isMailExist(mail):
newList = []
with open("usersData.json") as f:
readData = json.load(f)
newList = readData
newDict = {
"mail": mail,
"password": password
}
with open("usersData.json", "w") as f:
try:
newList.append(newDict)
jsonInfo = json.dumps(newList)
f.write(jsonInfo)
except Exception as ex:
print(ex)
finally:
f.close()
def createUser(self, mail, password):
self.mail = mail
self.password = password
while True: # mail adresi olusturma kosullari
try:
result = re.findall(r"@(.*?).com", mail)
countCharMailProvider = len(str(
result[0])) # Burada gmail ,hotmail gibi email saglayicilarinin uzanti karakter sayisi hesaplaniyor
except IndexError:
continue
if not re.findall("[@]", mail):
print("Mail adresi geçerli değildir!!!")
elif countCharMailProvider < 3: # @ ile .com arasinda karakter var mi kontrol ediyor
print("Mail adresi geçerli değildir!!!")
else:
print("Mail adresiniz uygundur...")
break
while True: # sifre olusturma kosullari
if not re.findall("[a-z]", password):
print("Şifreniz en az bir adet küçük harf içermek zorundadır!")
elif not re.findall("[A-Z]", password):
print("Şifreniz en az bir adet büyük harf içermek zorundadır!")
elif not re.findall("[0-9]", password):
print("Şifreniz en az bir adet rakam içermek zorundadır!")
else:
print("Şifreniz başarıyla kaydedildi...")
self.saveUserToJson(mail, password)
break
password = str(input("Lutfen sifrenizi tekrar giriniz...\n"))
self.password = password