-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.py
34 lines (28 loc) · 959 Bytes
/
account.py
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
import connDB
import bcrypt
FORMAT = 'utf-8'
def login(username, password):
usersList, numPeople = connDB.loadUsers()
usernameFound = False
passwordFound = False
for i in range(numPeople):
if username == usersList[i].getName():
usernameFound = True
reports = usersList[i].getReports()
if bcrypt.checkpw(password.encode(FORMAT), usersList[i].getPassword().encode(FORMAT)):
passwordFound = True
break
if usernameFound and passwordFound and reports < 3:
return True
else:
return False
def signUp(username, password):
validUsername = True
usersList, numPeople = connDB.loadUsers()
for i in range(numPeople):
if username == usersList[i].getName():
validUsername = False
break
if validUsername:
connDB.insertUsers(username, password)
return validUsername