-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcredentials.py
More file actions
114 lines (74 loc) · 2.71 KB
/
credentials.py
File metadata and controls
114 lines (74 loc) · 2.71 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import random
import pyperclip
import string
from user import User
class Credentials:
'''
This is a credentials class that creates new instances credentials
'''
credentials_list=[]
@classmethod
def check_user(cls, userName, userPassword):
'''
This is a method that first checks if the user is already in the user_list or not
'''
first_user=""
for user in User.user_list:
if (user.userName==userName and user.userPassword==userPassword):
first_user=user.userName
return first_user
def __init__(self,account,userName, password):
'''
A method that defines user credentials to be stored
'''
self.account=account
self.userName=userName
self.password=password
def save_credentials(self):
'''
A method that will help us save new credential details into the credentials_list
'''
Credentials.credentials_list.append(self)
def delete_credentials(self):
'''
This is a method that deletes the saved credentials in the credentials_list
'''
Credentials.credentials_list.remove(self)
@classmethod
def find_credentials(cls, account):
'''
This is a method that helps a user search for saved credentials using the account name
'''
for credential in cls.credentials_list:
if credential.account==account:
return credential
@classmethod
def copy_credentials(cls, account):
'''
A method that copies my credentials to the clipboard
'''
found_credentials=Credentials.find_credentials(account)
pyperclip.copy(found_credentials.account)
pyperclip.copy(found_credentials.userName)
pyperclip.copy(found_credentials.password)
@classmethod
def display_credentials(cls):
'''
This is a method that displays all credentials in the credential_list
'''
return cls.credentials_list
@classmethod
def credential_exist(cls, account):
'''
A method that checks if a credential already exists
'''
for credential in cls.credentials_list:
if credential.account==account:
return True
return False
def systemGeneratedPassword(passwordLength=10):
'''
Allows the system to generate a random password for you. A password that has has numerals, alphabets and special characters
'''
password=string.ascii_uppercase + string.ascii_lowercase + string.digits + "!@#$%^&*"
return ''.join(random.choice(password) for i in range (passwordLength))