Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ def signup(name, email, phone, password):
|
|
15 |
'Name__c': name.strip(),
|
16 |
'Email__c': email.strip(),
|
17 |
'Phone__c': phone.strip(),
|
18 |
-
'Password2__c': password.strip() #
|
19 |
})
|
20 |
return "Signup successful! You can now login."
|
21 |
except Exception as e:
|
@@ -32,23 +32,27 @@ def login(email, password):
|
|
32 |
result = sf.query(query)
|
33 |
|
34 |
if len(result['records']) == 0:
|
|
|
35 |
return "Invalid email or password.", None, None, None
|
36 |
|
37 |
user = result['records'][0]
|
38 |
stored_password = user['Password2__c']
|
39 |
|
|
|
|
|
|
|
|
|
40 |
# Compare plain-text passwords
|
41 |
if password == stored_password:
|
|
|
42 |
return "Login successful!", user['Name__c'], user['Email__c'], user['Phone__c']
|
43 |
else:
|
|
|
44 |
return "Invalid email or password.", None, None, None
|
45 |
except Exception as e:
|
|
|
46 |
return f"Error during login: {str(e)}", None, None, None
|
47 |
|
48 |
-
# Home Page Function
|
49 |
-
def home_page(name, email, phone):
|
50 |
-
return f"Welcome, {name}! Your email is {email} and your phone number is {phone}."
|
51 |
-
|
52 |
# Gradio Signup Page
|
53 |
def signup_page(name, email, phone, password):
|
54 |
response = signup(name, email, phone, password)
|
@@ -89,19 +93,7 @@ login_interface = gr.Interface(
|
|
89 |
title="Login Page"
|
90 |
)
|
91 |
|
92 |
-
#
|
93 |
-
home_interface = gr.Interface(
|
94 |
-
fn=home_page,
|
95 |
-
inputs=[
|
96 |
-
gr.Textbox(label="Name"),
|
97 |
-
gr.Textbox(label="Email"),
|
98 |
-
gr.Textbox(label="Phone"),
|
99 |
-
],
|
100 |
-
outputs=gr.Textbox(label="Welcome Message"),
|
101 |
-
title="Home Page"
|
102 |
-
)
|
103 |
-
|
104 |
-
# Combine All Pages in Gradio
|
105 |
with gr.Blocks() as app:
|
106 |
with gr.Tab("Signup"):
|
107 |
signup_interface.render()
|
@@ -109,8 +101,5 @@ with gr.Blocks() as app:
|
|
109 |
with gr.Tab("Login"):
|
110 |
login_interface.render()
|
111 |
|
112 |
-
|
113 |
-
home_interface.render()
|
114 |
-
|
115 |
-
# Launch the Gradio App
|
116 |
app.launch()
|
|
|
15 |
'Name__c': name.strip(),
|
16 |
'Email__c': email.strip(),
|
17 |
'Phone__c': phone.strip(),
|
18 |
+
'Password2__c': password.strip() # Use the new field Password2__c
|
19 |
})
|
20 |
return "Signup successful! You can now login."
|
21 |
except Exception as e:
|
|
|
32 |
result = sf.query(query)
|
33 |
|
34 |
if len(result['records']) == 0:
|
35 |
+
print(f"No user found with email: {email}")
|
36 |
return "Invalid email or password.", None, None, None
|
37 |
|
38 |
user = result['records'][0]
|
39 |
stored_password = user['Password2__c']
|
40 |
|
41 |
+
print(f"Entered Email: {email}")
|
42 |
+
print(f"Entered Password: {password}")
|
43 |
+
print(f"Stored Password: {stored_password}")
|
44 |
+
|
45 |
# Compare plain-text passwords
|
46 |
if password == stored_password:
|
47 |
+
print("Password matched!")
|
48 |
return "Login successful!", user['Name__c'], user['Email__c'], user['Phone__c']
|
49 |
else:
|
50 |
+
print("Password did not match!")
|
51 |
return "Invalid email or password.", None, None, None
|
52 |
except Exception as e:
|
53 |
+
print(f"Error during login: {str(e)}")
|
54 |
return f"Error during login: {str(e)}", None, None, None
|
55 |
|
|
|
|
|
|
|
|
|
56 |
# Gradio Signup Page
|
57 |
def signup_page(name, email, phone, password):
|
58 |
response = signup(name, email, phone, password)
|
|
|
93 |
title="Login Page"
|
94 |
)
|
95 |
|
96 |
+
# Combine Pages in Gradio
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
with gr.Blocks() as app:
|
98 |
with gr.Tab("Signup"):
|
99 |
signup_interface.render()
|
|
|
101 |
with gr.Tab("Login"):
|
102 |
login_interface.render()
|
103 |
|
104 |
+
# Launch Gradio App
|
|
|
|
|
|
|
105 |
app.launch()
|