Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,8 +11,6 @@ from simple_salesforce import Salesforce
|
|
| 11 |
sf = Salesforce(username='surendra@sathkrutha.com',
|
| 12 |
password='Lavanyanaga@123',
|
| 13 |
security_token='z7Wvk6mys7n8XjqbYKf3bwBh7')
|
| 14 |
-
# Utility Functions for Salesforce
|
| 15 |
-
|
| 16 |
def save_user(name, phone, email, password):
|
| 17 |
"""Save user details to Salesforce."""
|
| 18 |
try:
|
|
@@ -21,6 +19,7 @@ def save_user(name, phone, email, password):
|
|
| 21 |
result = sf.query(query)
|
| 22 |
|
| 23 |
if len(result['records']) > 0:
|
|
|
|
| 24 |
return False, "Email already exists. Please use a different email."
|
| 25 |
|
| 26 |
# Hash the password
|
|
@@ -46,6 +45,7 @@ def check_credentials(email, password):
|
|
| 46 |
result = sf.query(query)
|
| 47 |
|
| 48 |
if len(result['records']) == 0:
|
|
|
|
| 49 |
return False, "Invalid email or password."
|
| 50 |
|
| 51 |
# Retrieve the stored hashed password
|
|
@@ -60,30 +60,6 @@ def check_credentials(email, password):
|
|
| 60 |
print(f"Error checking credentials: {e}")
|
| 61 |
return False, "An error occurred during login. Please try again."
|
| 62 |
|
| 63 |
-
# Authentication and Navigation Logic
|
| 64 |
-
def authenticate_user(email, password):
|
| 65 |
-
"""Authenticate user during login."""
|
| 66 |
-
success, message = check_credentials(email, password)
|
| 67 |
-
if success:
|
| 68 |
-
return gr.update(visible=False), gr.update(visible=True), message
|
| 69 |
-
else:
|
| 70 |
-
return gr.update(visible=True), gr.update(visible=False), message
|
| 71 |
-
|
| 72 |
-
def navigate_to_signup():
|
| 73 |
-
"""Navigate to the signup page."""
|
| 74 |
-
return gr.update(visible=False), gr.update(visible=True)
|
| 75 |
-
|
| 76 |
-
def create_account(name, phone, email, password):
|
| 77 |
-
"""Create a new account during signup."""
|
| 78 |
-
success, message = save_user(name, phone, email, password)
|
| 79 |
-
if success:
|
| 80 |
-
return message, gr.update(visible=True), gr.update(visible=False)
|
| 81 |
-
else:
|
| 82 |
-
return message, gr.update(visible=False), gr.update(visible=True)
|
| 83 |
-
|
| 84 |
-
def navigate_to_login():
|
| 85 |
-
"""Navigate back to the login page."""
|
| 86 |
-
return gr.update(visible=True), gr.update(visible=False)
|
| 87 |
|
| 88 |
|
| 89 |
# Function to load the menu data
|
|
|
|
| 11 |
sf = Salesforce(username='surendra@sathkrutha.com',
|
| 12 |
password='Lavanyanaga@123',
|
| 13 |
security_token='z7Wvk6mys7n8XjqbYKf3bwBh7')
|
|
|
|
|
|
|
| 14 |
def save_user(name, phone, email, password):
|
| 15 |
"""Save user details to Salesforce."""
|
| 16 |
try:
|
|
|
|
| 19 |
result = sf.query(query)
|
| 20 |
|
| 21 |
if len(result['records']) > 0:
|
| 22 |
+
# Email already exists
|
| 23 |
return False, "Email already exists. Please use a different email."
|
| 24 |
|
| 25 |
# Hash the password
|
|
|
|
| 45 |
result = sf.query(query)
|
| 46 |
|
| 47 |
if len(result['records']) == 0:
|
| 48 |
+
# Email not found
|
| 49 |
return False, "Invalid email or password."
|
| 50 |
|
| 51 |
# Retrieve the stored hashed password
|
|
|
|
| 60 |
print(f"Error checking credentials: {e}")
|
| 61 |
return False, "An error occurred during login. Please try again."
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
|
| 65 |
# Function to load the menu data
|