nagasurendra commited on
Commit
0ffcb00
·
verified ·
1 Parent(s): f8d7ccb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -0
app.py CHANGED
@@ -22,22 +22,33 @@ def signup(name, email, phone, password):
22
  # Login Function
23
  def login(email, password):
24
  try:
 
 
 
25
  query = f"SELECT Name__c, Email__c, Phone__c, Password__c FROM User_Login__c WHERE Email__c = '{email}'"
26
  result = sf.query(query)
27
 
28
  if len(result['records']) == 0:
 
29
  return "Invalid email or password.", None, None, None
30
 
31
  user = result['records'][0]
32
  stored_password = user['Password__c']
33
 
 
 
 
34
  if password == stored_password:
 
35
  return "Login successful!", user['Name__c'], user['Email__c'], user['Phone__c']
36
  else:
 
37
  return "Invalid email or password.", None, None, None
38
  except Exception as e:
 
39
  return f"Error during login: {str(e)}", None, None, None
40
 
 
41
  # Gradio Signup Page
42
  def signup_page(name, email, phone, password):
43
  response = signup(name, email, phone, password)
 
22
  # Login Function
23
  def login(email, password):
24
  try:
25
+ email = email.strip() # Remove any extra spaces
26
+ password = password.strip() # Remove any extra spaces
27
+
28
  query = f"SELECT Name__c, Email__c, Phone__c, Password__c FROM User_Login__c WHERE Email__c = '{email}'"
29
  result = sf.query(query)
30
 
31
  if len(result['records']) == 0:
32
+ print(f"No user found with email: {email}")
33
  return "Invalid email or password.", None, None, None
34
 
35
  user = result['records'][0]
36
  stored_password = user['Password__c']
37
 
38
+ print(f"Entered Password: {password}")
39
+ print(f"Stored Password: {stored_password}")
40
+
41
  if password == stored_password:
42
+ print("Password matched!")
43
  return "Login successful!", user['Name__c'], user['Email__c'], user['Phone__c']
44
  else:
45
+ print("Password did not match!")
46
  return "Invalid email or password.", None, None, None
47
  except Exception as e:
48
+ print(f"Error during login: {str(e)}")
49
  return f"Error during login: {str(e)}", None, None, None
50
 
51
+
52
  # Gradio Signup Page
53
  def signup_page(name, email, phone, password):
54
  response = signup(name, email, phone, password)