Spaces:
Sleeping
Sleeping
| """Authentication module for Robata CRM""" | |
| import streamlit as st | |
| def check_authentication() -> bool: | |
| """Check if user is authenticated and handle login if not""" | |
| if 'user' not in st.session_state: | |
| return show_login() | |
| return True | |
| def show_login() -> bool: | |
| """Show login form and handle authentication""" | |
| st.title("🔐 Login to Robata CRM") | |
| # Create three columns for centering | |
| _, center_col, _ = st.columns([1, 2, 1]) | |
| with center_col: | |
| st.markdown("""### Demo Login Credentials: | |
| **Sales Representative** | |
| - Email: sales@robata.com | |
| - Password: demo123 | |
| **Regional Lead** | |
| - Email: lead@robata.com | |
| - Password: demo123 | |
| **Head of Sales** | |
| - Email: head@robata.com | |
| - Password: demo123 | |
| """) | |
| # Login form | |
| with st.form("login_form"): | |
| email = st.text_input("Email") | |
| password = st.text_input("Password", type="password") | |
| submitted = st.form_submit_button("Login") | |
| if submitted: | |
| if authenticate_user(email, password): | |
| st.success("Login successful!") | |
| return True | |
| else: | |
| st.error("Invalid credentials") | |
| return False | |
| def authenticate_user(email: str, password: str) -> bool: | |
| """Authenticate user credentials""" | |
| # Demo users with their roles | |
| demo_users = { | |
| "sales@robata.com": { | |
| "password": "demo123", | |
| "name": "Alex Thompson", | |
| "role": "sales_rep", | |
| "company": "Robata Inc", | |
| "id": "sales_1", | |
| "department": "Sales", | |
| "title": "Senior Sales Executive" | |
| }, | |
| "lead@robata.com": { | |
| "password": "demo123", | |
| "name": "Sarah Chen", | |
| "role": "regional_lead", | |
| "company": "Robata Inc", | |
| "id": "lead_1", | |
| "department": "Sales", | |
| "title": "Regional Sales Director - EMEA" | |
| }, | |
| "head@robata.com": { | |
| "password": "demo123", | |
| "name": "James Wilson", | |
| "role": "head_of_sales", | |
| "company": "Robata Inc", | |
| "id": "head_1", | |
| "department": "Sales", | |
| "title": "Head of Sales" | |
| } | |
| } | |
| if email in demo_users and password == demo_users[email]["password"]: | |
| # Store user info in session state | |
| st.session_state.user = { | |
| "id": demo_users[email]["id"], | |
| "name": demo_users[email]["name"], | |
| "role": demo_users[email]["role"], | |
| "company": demo_users[email]["company"], | |
| "department": demo_users[email]["department"], | |
| "title": demo_users[email]["title"], | |
| "email": email | |
| } | |
| return True | |
| return False |