Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -95,40 +95,40 @@ if name in user_data:
|
|
95 |
save_user_data(user_data)
|
96 |
display_message('π PIN created successfully! π', "π")
|
97 |
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
while count < 3:
|
105 |
-
if pin.isdigit() and pin == user_data[name]['pin']:
|
106 |
-
break
|
107 |
-
else:
|
108 |
-
count += 1
|
109 |
-
display_message('β Invalid PIN. Please try again. β', "β")
|
110 |
|
111 |
-
|
112 |
-
if
|
113 |
-
|
114 |
else:
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
else:
|
133 |
# New user; create an entry with default values
|
134 |
user_data[name] = {'pin': '', 'amount': 0}
|
@@ -144,3 +144,11 @@ else:
|
|
144 |
user_data[name]['pin'] = new_pin
|
145 |
save_user_data(user_data)
|
146 |
display_message('π PIN created successfully! π', "π")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
save_user_data(user_data)
|
96 |
display_message('π PIN created successfully! π', "π")
|
97 |
|
98 |
+
# comparing pin
|
99 |
+
count = 0
|
100 |
+
with st.form(key='pin_entry_form'):
|
101 |
+
pin = st.text_input('Please enter your PIN:', type='password', key="pin_input_existing")
|
102 |
+
st.form_submit_button('Submit PIN')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
103 |
|
104 |
+
while count < 3:
|
105 |
+
if pin.isdigit() and pin == user_data[name]['pin']:
|
106 |
+
break
|
107 |
else:
|
108 |
+
count += 1
|
109 |
+
display_message('β Invalid PIN. Please try again. β', "β")
|
110 |
+
|
111 |
+
# in case of a valid pin - continuing, or exiting
|
112 |
+
if count == 3:
|
113 |
+
display_message('β 3 UNSUCCESSFUL PIN ATTEMPTS, EXITING. YOUR CARD HAS BEEN LOCKED β', "β")
|
114 |
+
else:
|
115 |
+
display_message(f'π LOGIN SUCCESSFUL, CONTINUE {name.capitalize()}! π', "π")
|
116 |
+
|
117 |
+
# Main menu
|
118 |
+
options = ['View Balance', 'Withdraw Cash', 'Deposit Cash', 'Change PIN', 'Quit']
|
119 |
+
response = st.selectbox('Select an option:', options, key="menu_selectbox_existing")
|
120 |
+
|
121 |
+
if response == 'View Balance':
|
122 |
+
view_balance(user_data)
|
123 |
+
elif response == 'Withdraw Cash':
|
124 |
+
withdraw_cash(user_data)
|
125 |
+
elif response == 'Deposit Cash':
|
126 |
+
deposit_cash(user_data)
|
127 |
+
elif response == 'Change PIN':
|
128 |
+
change_pin(user_data)
|
129 |
+
elif response == 'Quit':
|
130 |
+
save_user_data(user_data)
|
131 |
+
display_message('π Thank you for using our ATM. Have a great day! π', "π")
|
132 |
else:
|
133 |
# New user; create an entry with default values
|
134 |
user_data[name] = {'pin': '', 'amount': 0}
|
|
|
144 |
user_data[name]['pin'] = new_pin
|
145 |
save_user_data(user_data)
|
146 |
display_message('π PIN created successfully! π', "π")
|
147 |
+
|
148 |
+
# Main menu (for new user)
|
149 |
+
options_new_user = ['Quit']
|
150 |
+
response_new_user = st.selectbox('Select an option:', options_new_user, key="menu_selectbox_new_user")
|
151 |
+
|
152 |
+
if response_new_user == 'Quit':
|
153 |
+
save_user_data(user_data)
|
154 |
+
display_message('π Thank you for using our ATM. Have a great day! π', "π")
|