artintel235 commited on
Commit
c29d33d
·
verified ·
1 Parent(s): 9c6b363

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -29
app.py CHANGED
@@ -24,20 +24,6 @@ if "logged_in" not in st.session_state:
24
  if "current_user" not in st.session_state:
25
  st.session_state.current_user = None
26
 
27
- # Function to send verification email
28
- def send_verification_email(email, verification_link):
29
- subject = "Verify Your Email"
30
- body = f"Please click the link to verify your email: {verification_link}"
31
-
32
- msg = MIMEText(body)
33
- msg['Subject'] = subject
34
- msg['From'] = sender_email
35
- msg['To'] = email
36
-
37
- with smtplib.SMTP_SSL('smtp.example.com', 465) as server:
38
- server.login(sender_email, email_pass)
39
- server.sendmail(sender_email, [email], msg.as_string())
40
-
41
  # Callback for registration
42
  def register_callback():
43
  email = st.session_state.reg_email
@@ -45,13 +31,7 @@ def register_callback():
45
  try:
46
  # Create a new user in Firebase
47
  user = auth.create_user(email=email, password=password)
48
-
49
- # Generate email verification link
50
- verification_link = auth.generate_email_verification_link(email)
51
-
52
- # Send verification email
53
- send_verification_email(email, verification_link)
54
- st.success("Registration successful! Please check your email to verify your account.")
55
  except Exception as e:
56
  st.error(f"Registration failed: {e}")
57
 
@@ -62,14 +42,9 @@ def login_callback():
62
  try:
63
  # Authenticate user with Firebase
64
  user = auth.get_user_by_email(email)
65
-
66
- # Check if email is verified
67
- if user.email_verified:
68
- st.session_state.logged_in = True
69
- st.session_state.current_user = user.uid # Store the user UID in session state
70
- st.success("Logged in successfully!")
71
- else:
72
- st.error("Please verify your email before logging in.")
73
  except Exception as e:
74
  st.error(f"Login failed: {e}")
75
 
 
24
  if "current_user" not in st.session_state:
25
  st.session_state.current_user = None
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  # Callback for registration
28
  def register_callback():
29
  email = st.session_state.reg_email
 
31
  try:
32
  # Create a new user in Firebase
33
  user = auth.create_user(email=email, password=password)
34
+ st.success("Registration successful! Please log in.")
 
 
 
 
 
 
35
  except Exception as e:
36
  st.error(f"Registration failed: {e}")
37
 
 
42
  try:
43
  # Authenticate user with Firebase
44
  user = auth.get_user_by_email(email)
45
+ st.session_state.logged_in = True
46
+ st.session_state.current_user = user.uid # Store the user UID in session state
47
+ st.success("Logged in successfully!")
 
 
 
 
 
48
  except Exception as e:
49
  st.error(f"Login failed: {e}")
50