-
Notifications
You must be signed in to change notification settings - Fork 192
Expand file tree
/
Copy pathauth.py
More file actions
35 lines (25 loc) · 963 Bytes
/
auth.py
File metadata and controls
35 lines (25 loc) · 963 Bytes
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
from datetime import datetime
from time import sleep
import pytz
import streamlit as st
from src.utils.greeting import GetRandomWelcomeMessage, GreetUser
def unix_to_ist(timestamp):
india_tz = pytz.timezone("Asia/Kolkata")
format_str = "%I:%M:%S %p IST"
return datetime.fromtimestamp(timestamp, pytz.utc).astimezone(india_tz).strftime(format_str)
def auth():
if st.user and not st.user.is_logged_in:
st.title("🔐 Login Required")
st.write("Please authenticate using your Google account to access your profile.")
if st.button("🔓 Authenticate with Google"):
st.login("google")
else:
st.title(f"🙏 {GreetUser(st.user.given_name)}")
st.success(GetRandomWelcomeMessage(), icon="🤝")
st.image(st.user.picture, caption=st.user.name)
st.write("Email:", st.user.email)
if st.button("Log out"):
st.toast(f"Goodbye, {st.user.name}! See you soon!", icon="🚪")
sleep(2)
st.logout()
auth()