nagasurendra commited on
Commit
3fd1de3
·
verified ·
1 Parent(s): bcdb5d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -1,6 +1,26 @@
1
  import gradio as gr
2
  import pandas as pd
3
  from bcrypt import hashpw, gensalt, checkpw
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
 
6
  # Function to load the menu data
 
1
  import gradio as gr
2
  import pandas as pd
3
  from bcrypt import hashpw, gensalt, checkpw
4
+ from database_handler import check_credentials, save_user
5
+
6
+ # Authentication and Navigation Logic
7
+ def authenticate_user(email, password):
8
+ if check_credentials(email, password):
9
+ return gr.update(visible=False), gr.update(visible=True), ""
10
+ else:
11
+ return gr.update(visible=True), gr.update(visible=False), "Invalid email or password. Try again."
12
+
13
+ def navigate_to_signup():
14
+ return gr.update(visible=False), gr.update(visible=True)
15
+
16
+ def create_account(name, phone, email, password):
17
+ if save_user(name, phone, email, password):
18
+ return "Account created successfully! You can now log in.", gr.update(visible=True), gr.update(visible=False)
19
+ else:
20
+ return "Email already exists. Try logging in.", gr.update(visible=False), gr.update(visible=True)
21
+
22
+ def navigate_to_login():
23
+ return gr.update(visible=True), gr.update(visible=False)
24
 
25
 
26
  # Function to load the menu data