-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.py
59 lines (50 loc) · 1.52 KB
/
users.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
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
class Users:
'''
Class that generates new instances of users
'''
users_list = []
def __init__ (self, username, login_password):
'''
___init___ method that helps us define properties for our objects.
Args:
username: New username
login_password: New user password
'''
self.username = username
self.login_password = login_password
def add_user(self):
'''
add user details method saves user object into users list
'''
Users.users_list.append(self)
def delete_user(self):
'''
delete user details method removes user object from users list
'''
Users.users_list.remove(self)
@classmethod
def find_by_username(cls, username):
'''
authenticate user username
Args:
username : name used by user to login
Returns:
user
'''
for user in Users.users_list:
if user.username == username:
return user
@classmethod
def user_exists(cls, username, login_password):
'''
authenticate user username and password by checking if user exists in the users list
Args:
username : name used by user to login
login_password: password for the user
Returns:
boolean
'''
for user in Users.users_list:
if user.username == username and user.login_password == login_password:
return True
return False