Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -25,8 +25,12 @@ def register_callback():
|
|
25 |
password = st.session_state.reg_password
|
26 |
try:
|
27 |
# Create a new user in Firebase
|
28 |
-
user = auth.
|
29 |
-
st.success("Registration successful! Please
|
|
|
|
|
|
|
|
|
30 |
except Exception as e:
|
31 |
st.error(f"Registration failed: {e}")
|
32 |
|
@@ -36,10 +40,19 @@ def login_callback():
|
|
36 |
password = st.session_state.login_password
|
37 |
try:
|
38 |
# Authenticate user with Firebase
|
39 |
-
user = auth.
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
except Exception as e:
|
44 |
st.error(f"Login failed: {e}")
|
45 |
|
@@ -86,4 +99,4 @@ if st.session_state.logged_in:
|
|
86 |
main_app()
|
87 |
else:
|
88 |
registration_form()
|
89 |
-
login_form()
|
|
|
25 |
password = st.session_state.reg_password
|
26 |
try:
|
27 |
# Create a new user in Firebase
|
28 |
+
user = auth.create_user_with_email_and_password(email, password)
|
29 |
+
st.success("Registration successful! Please check your email for verification.")
|
30 |
+
|
31 |
+
# Send verification email
|
32 |
+
auth.send_email_verification(user['idToken'])
|
33 |
+
st.info("A verification email has been sent to your email address.")
|
34 |
except Exception as e:
|
35 |
st.error(f"Registration failed: {e}")
|
36 |
|
|
|
40 |
password = st.session_state.login_password
|
41 |
try:
|
42 |
# Authenticate user with Firebase
|
43 |
+
user = auth.sign_in_with_email_and_password(email, password)
|
44 |
+
|
45 |
+
# Check if email is verified
|
46 |
+
user_info = auth.get_account_info(user['idToken'])
|
47 |
+
if user_info['users'][0]['emailVerified']:
|
48 |
+
st.session_state.logged_in = True
|
49 |
+
st.session_state.current_user = user['localId']
|
50 |
+
st.success("Logged in successfully!")
|
51 |
+
else:
|
52 |
+
st.error("Please verify your email address before logging in.")
|
53 |
+
# Resend verification email if needed
|
54 |
+
auth.send_email_verification(user['idToken'])
|
55 |
+
st.info("A new verification email has been sent to your email address.")
|
56 |
except Exception as e:
|
57 |
st.error(f"Login failed: {e}")
|
58 |
|
|
|
99 |
main_app()
|
100 |
else:
|
101 |
registration_form()
|
102 |
+
login_form()
|