File size: 2,067 Bytes
db7b744
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st


def showSidebar():
    with st.sidebar:
        if "user" in st.session_state and "token" in st.session_state:
            st.markdown("""
                <style>
                .user-info {
                    display: flex;
                    align-items: center;
                    padding: 10px;
                    background-color: rgba(255, 255, 255, 0.1);
                    border-radius: 5px;
                    margin-bottom: 10px;
                    margin-top: -2rem;
                }
                .user-avatar {
                    width: 40px;
                    height: 40px;
                    border-radius: 50%;
                    margin-right: 10px;
                }
                .user-details {
                    flex-grow: 1;
                }
                .user-name {
                    font-weight: bold;
                    margin: 0;
                }
                .user-email {
                    font-size: 0.8em;
                    color: #888;
                    margin: 0;
                }
                </style>
                """, unsafe_allow_html=True)

            user_avatar = st.session_state["user"].get("picture", "https://example.com/default-avatar.png")
            user_name = st.session_state["user"].get("name", "User")
            user_email = st.session_state["user"].get("email", "")

            st.markdown(f"""
                <div class="user-info">
                    <img src="{user_avatar}" class="user-avatar">
                    <div class="user-details">
                        <p class="user-name">{user_name}</p>
                        <p class="user-email">{user_email}</p>
                    </div>
                </div>
                """, unsafe_allow_html=True)

            if st.button("Logout", key="logout_button", type="secondary", use_container_width=True):
                for key in ["token", "user"]:
                    if key in st.session_state:
                        del st.session_state[key]
                st.rerun()