File size: 2,903 Bytes
1923999
9ce972f
 
 
1923999
9ce972f
 
 
 
 
1923999
 
9ce972f
1923999
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9ce972f
1923999
 
 
 
 
 
 
 
 
 
 
 
 
9ce972f
1923999
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
"""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