forked from xyluz/pythonclass
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.py
More file actions
118 lines (67 loc) · 2.35 KB
/
auth.py
File metadata and controls
118 lines (67 loc) · 2.35 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
109
110
111
112
113
114
115
#register
# - first name, last name, password, email
# - generaten user account
#login
# - account number & password
#bank operations
#Initializing the system
import random
database = {} #dictionary
def init():
print("Welcome to bankPHP")
haveAccount = int(input("Do you have account with us: 1 (yes) 2 (no) \n"))
if(haveAccount == 1):
login()
elif(haveAccount == 2):
register()
else:
print("You have selected invalid option")
init()
def login():
print("********* Login ***********")
accountNumberFromUser = int(input("What is your account number? \n"))
password = input("What is your password \n")
for accountNumber,userDetails in database.items():
if(accountNumber == accountNumberFromUser):
if(userDetails[3] == password):
bankOperation(userDetails)
print('Invalid account or password')
login()
def register():
print("****** Register *******")
email = input("What is your email address? \n")
first_name = input("What is your first name? \n")
last_name = input("What is your last name? \n")
password = input("create a password for yourself \n")
accountNumber = generationAccountNumber()
database[accountNumber] = [ first_name, last_name, email, password ]
print("Your Account Has been created")
print(" == ==== ====== ===== ===")
print("Your account number is: %d" % accountNumber)
print("Make sure you keep it safe")
print(" == ==== ====== ===== ===")
login()
def bankOperation(user):
print("Welcome %s %s " % ( user[0], user[1] ) )
selectedOption = int(input("What would you like to do? (1) deposit (2) withdrawal (3) Logout (4) Exit \n"))
if(selectedOption == 1):
depositOperation()
elif(selectedOption == 2):
withdrawalOperation()
elif(selectedOption == 3):
logout()
elif(selectedOption == 4):
exit()
else:
print("Invalid option selected")
bankOperation(user)
def withdrawalOperation():
print("withdrawal")
def depositOperation():
print("Deposit Operations")
def generationAccountNumber():
return random.randrange(1111111111,9999999999)
def logout():
login()
#### ACTUAL BANKING SYSTEM #####
init()