import streamlit as st import firebase_admin from firebase_admin import credentials, auth import streamlit as st st.set_page_config(initial_sidebar_state="collapsed") st.markdown( """ """, unsafe_allow_html=True, ) # Check if Firebase Admin SDK has been initialized if not firebase_admin._apps: # Initialize Firebase Admin SDK cred = credentials.Certificate("tokens/gdfg-cf9d9-firebase-adminsdk-593q1-5d02a16c64.json") # Update with your own service account key firebase_admin.initialize_app(cred) # Function to sign up a new user def signup(email, password): try: user = auth.create_user(email=email, password=password) st.success("User created successfully!") return True except Exception as e: st.error(f"Error creating user: {e}") return False # Function to log in existing user def login(email, password): try: user = auth.get_user_by_email(email) st.session_state['logged_in'] = True # Initialize the 'logged_in' key st.success("Login successful!") return True except Exception as e: st.error(f"Error logging in: {e}") return False # Main function def main(): st.title("VX1000 BetaV") # Sign up form with st.form("signup_form"): st.header("Sign Up") email = st.text_input("Email") password = st.text_input("Password", type="password") signup_button = st.form_submit_button("Sign Up") if signup_button: if signup(email, password): # Redirect to another Python code after signup st.success("Check your Mail") # Insert code for redirection here # Login form with st.form("login_form"): st.header("Login") email = st.text_input("Email") password = st.text_input("Password", type="password") login_button = st.form_submit_button("Login") if login_button: if login(email, password): if 'logged_in' in st.session_state and st.session_state['logged_in']: # Check if logged in st.switch_page("pages/dashboard.py")# Redirect to new page after successful login else: st.warning("An unexpected error occurred. Please try again.") st.markdown( """