-
Notifications
You must be signed in to change notification settings - Fork 0
/
Authentication.py
105 lines (88 loc) · 3.82 KB
/
Authentication.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
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
import getpass
import time
import hashlib
from typing import List
def login() -> str:
print('Welcome To Cypha Python Systems')
print('Please Wait...')
time.sleep(3)
while True:
choice = input('Login As: ').lower()
if choice in ['admin']:
return choice
else:
print('Invalid choice. Please try again.')
def authenticate(name: str, password: str, stored_password: str) -> bool:
hashed_password = hashlib.sha256(password.encode()).hexdigest()
return name in ['chamba', 'nartey'] and hashed_password == stored_password
def check_assigned_work() -> str:
return 'You have no assigned work'
def check_team_members() -> str:
return 'No available members. Thank you.'
def check_password() -> str:
return getpass.getpass()
def reset_password() -> None:
print('Resetting password...')
# Code to reset password
def main() -> None:
stored_password = 'admin123'
while True:
choice = login()
if choice == 'admin':
name = input('Enter your name: ').lower()
password = check_password()
if authenticate(name, password, stored_password):
print('Please Wait....')
time.sleep(2)
print(f'Welcome, {name.title()}')
while True:
print('1. Check Assigned Work')
print('2. Check Team Members')
print('3. Password')
print('4. Exit')
option = int(input('Select your option: '))
if option == 1:
print('Please wait...')
time.sleep(2)
print('----------------------------------------')
print(check_assigned_work())
print('----------------------------------------')
elif option == 2:
print('Please wait...')
time.sleep(2)
print('----------------------------------------')
print(check_team_members())
print('----------------------------------------')
elif option == 3:
print('Please wait...')
time.sleep(3)
while True:
print('----------------------------------------')
print('1. Check Password')
print('2. Reset Password')
print('4. Exit')
pass_option = int(input('Select your option: '))
if pass_option == 1:
print('----------------------------------------')
print('Please wait...')
time.sleep(2)
print('----------------------------------------')
print('Your current password is:', password)
print('----------------------------------------')
elif pass_option == 2:
reset_password()
elif pass_option == 4:
break
else:
print('Invalid option. Please try again.')
elif option == 4:
print('----------------------------------------')
print('Exiting Please Wait....')
time.sleep(3)
break
else:
print('Invalid option. Please try again.')
else:
print('Invalid Username Or Password')
if __name__ == '__main__':
main()