nagasurendra commited on
Commit
467bcc5
·
verified ·
1 Parent(s): 73ba9e6

Update components/login_signup.py

Browse files
Files changed (1) hide show
  1. components/login_signup.py +6 -6
components/login_signup.py CHANGED
@@ -5,7 +5,7 @@ from utils.state_management import state
5
  def login_signup():
6
  def authenticate(email, password):
7
  customers = read_excel('data/customers.xlsx')
8
- user = customers.get(email)
9
  if user and user['Password'] == password:
10
  state["user"] = user
11
  return "Login Successful!"
@@ -13,12 +13,12 @@ def login_signup():
13
 
14
  def register(name, email, password, preferences, allergies, occasion):
15
  customers = read_excel('data/customers.xlsx')
16
- if email in customers:
17
  return "Email already exists!"
18
- customers[email] = {
19
- "Name": name, "Password": password, "Preferences": preferences,
20
- "Allergies": allergies, "Occasion": occasion
21
- }
22
  write_excel('data/customers.xlsx', customers)
23
  return "Registration Successful!"
24
 
 
5
  def login_signup():
6
  def authenticate(email, password):
7
  customers = read_excel('data/customers.xlsx')
8
+ user = next((c for c in customers if c['Email'] == email), None)
9
  if user and user['Password'] == password:
10
  state["user"] = user
11
  return "Login Successful!"
 
13
 
14
  def register(name, email, password, preferences, allergies, occasion):
15
  customers = read_excel('data/customers.xlsx')
16
+ if any(c['Email'] == email for c in customers):
17
  return "Email already exists!"
18
+ customers.append({
19
+ "Name": name, "Email": email, "Password": password,
20
+ "Preferences": preferences, "Allergies": allergies, "Occasion": occasion
21
+ })
22
  write_excel('data/customers.xlsx', customers)
23
  return "Registration Successful!"
24