-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredentials.py
More file actions
65 lines (57 loc) · 1.78 KB
/
credentials.py
File metadata and controls
65 lines (57 loc) · 1.78 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
import random
import string
class Credentials:
credential_list = [] #Empty credential list
"""
Class that generates new instances of credentials
"""
def __init__(self,account,user_name,password,email):
"""
__init__ method helps us to define properties for our objects
"""
self.account = account
self.user_name = user_name
self.password = password
self.email = email
def save_credentials(self):
"""
save_credentials method saves credentials into the credential_list
"""
Credentials.credential_list.append(self)
def delete_credentials(self):
"""
delete_credentials method to delete credentials from the credential_list
"""
Credentials.credential_list.remove(self)
@classmethod
def find_by_account(cls,account):
"""
find credentials by account
"""
for credentials in cls.credential_list:
if credentials.account == account:
return credentials
@classmethod
def credentials_exist(cls,account):
"""
check if credentials exist
"""
for credentials in cls.credential_list:
if credentials.account == account:
return True
return False
@classmethod
def display_credentials(cls):
"""
method that returns the credential_list
"""
return cls.credential_list
@classmethod
def generate_password(cls,password_length):
"""
method to generate a random password for a user creating a new account
"""
alpha = string.ascii_letters + string.digits
password = ''.join(random.choice(alpha)
for i in range(password_length))
return password