Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,10 +5,7 @@ import bcrypt
|
|
| 5 |
import gradio as gr
|
| 6 |
from simple_salesforce import Salesforce
|
| 7 |
# Salesforce Connection
|
| 8 |
-
sf = Salesforce(username='
|
| 9 |
-
password='Lavanyanaga@123',
|
| 10 |
-
security_token='z7Wvk6mys7n8XjqbYKf3bwBh7')
|
| 11 |
-
|
| 12 |
|
| 13 |
|
| 14 |
# Function to Hash Password
|
|
@@ -25,7 +22,7 @@ def signup(name, email, phone, password):
|
|
| 25 |
email = email.strip()
|
| 26 |
|
| 27 |
# Check if the email already exists in Salesforce
|
| 28 |
-
query = f"SELECT Id FROM
|
| 29 |
result = sf.query(query)
|
| 30 |
|
| 31 |
if len(result['records']) > 0:
|
|
@@ -36,11 +33,11 @@ def signup(name, email, phone, password):
|
|
| 36 |
hashed_password = hash_password(password)
|
| 37 |
|
| 38 |
# Create the new user record
|
| 39 |
-
sf.
|
| 40 |
-
'
|
| 41 |
'Email__c': email,
|
| 42 |
-
'
|
| 43 |
-
'
|
| 44 |
})
|
| 45 |
return "Signup successful! You can now login."
|
| 46 |
except Exception as e:
|
|
@@ -53,14 +50,14 @@ def login(email, password):
|
|
| 53 |
password = password.strip()
|
| 54 |
|
| 55 |
# Query Salesforce for user details
|
| 56 |
-
query = f"SELECT
|
| 57 |
result = sf.query(query)
|
| 58 |
|
| 59 |
if len(result['records']) == 0:
|
| 60 |
return "Invalid email or password.", None, None, None
|
| 61 |
|
| 62 |
user = result['records'][0]
|
| 63 |
-
stored_password = user['
|
| 64 |
|
| 65 |
print(f"Entered Email: {email}")
|
| 66 |
print(f"Entered Password: {password}")
|
|
@@ -69,7 +66,7 @@ def login(email, password):
|
|
| 69 |
# Verify the entered password with the stored hash
|
| 70 |
if verify_password(password, stored_password):
|
| 71 |
print("Password matched!")
|
| 72 |
-
return "Login successful!", user['
|
| 73 |
else:
|
| 74 |
print("Password did not match!")
|
| 75 |
return "Invalid email or password.", None, None, None
|
|
|
|
| 5 |
import gradio as gr
|
| 6 |
from simple_salesforce import Salesforce
|
| 7 |
# Salesforce Connection
|
| 8 |
+
sf = Salesforce(username='diggavalli98@gmail.com', password='Sati@1020', security_token='sSSjyhInIsUohKpG8sHzty2q')
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
# Function to Hash Password
|
|
|
|
| 22 |
email = email.strip()
|
| 23 |
|
| 24 |
# Check if the email already exists in Salesforce
|
| 25 |
+
query = f"SELECT Id FROM Customer_Login__c WHERE Email__c = '{email}'"
|
| 26 |
result = sf.query(query)
|
| 27 |
|
| 28 |
if len(result['records']) > 0:
|
|
|
|
| 33 |
hashed_password = hash_password(password)
|
| 34 |
|
| 35 |
# Create the new user record
|
| 36 |
+
sf.Customer_Login__c.create({
|
| 37 |
+
'Name': name.strip(),
|
| 38 |
'Email__c': email,
|
| 39 |
+
'Phone_Number__c': phone.strip(),
|
| 40 |
+
'Password__c': hashed_password # Use Password3__c field for hashed passwords
|
| 41 |
})
|
| 42 |
return "Signup successful! You can now login."
|
| 43 |
except Exception as e:
|
|
|
|
| 50 |
password = password.strip()
|
| 51 |
|
| 52 |
# Query Salesforce for user details
|
| 53 |
+
query = f"SELECT Name, Email__c, Phone_Number__c, Password__c FROM Customer_Login__c WHERE Email__c = '{email}'"
|
| 54 |
result = sf.query(query)
|
| 55 |
|
| 56 |
if len(result['records']) == 0:
|
| 57 |
return "Invalid email or password.", None, None, None
|
| 58 |
|
| 59 |
user = result['records'][0]
|
| 60 |
+
stored_password = user['Password__c']
|
| 61 |
|
| 62 |
print(f"Entered Email: {email}")
|
| 63 |
print(f"Entered Password: {password}")
|
|
|
|
| 66 |
# Verify the entered password with the stored hash
|
| 67 |
if verify_password(password, stored_password):
|
| 68 |
print("Password matched!")
|
| 69 |
+
return "Login successful!", user['Name'], user['Email__c'], user['Phone_Number__c']
|
| 70 |
else:
|
| 71 |
print("Password did not match!")
|
| 72 |
return "Invalid email or password.", None, None, None
|