34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import streamlit as st
|
|
|
|
|
|
def protect_application(render_exit: bool = True) -> None:
|
|
_ = render_exit
|
|
|
|
|
|
def get_jwt_token() -> dict[str, str] | None:
|
|
email = st.session_state.get("local_user_email")
|
|
username = st.session_state.get("local_username")
|
|
full_name = st.session_state.get("local_full_name")
|
|
|
|
if not email:
|
|
cols = st.columns([1, 2, 1])
|
|
with cols[1]:
|
|
with st.container(border=True):
|
|
st.info("Локальный режим: введите профиль пользователя")
|
|
email = st.text_input("Email", key="local_user_email")
|
|
username = st.text_input("Username", key="local_username")
|
|
full_name = st.text_input("Full name", key="local_full_name")
|
|
|
|
if not email:
|
|
st.stop()
|
|
|
|
st.session_state["local_mock_profile"] = {
|
|
"email": email,
|
|
"preferred_username": username or email.split("@")[0],
|
|
"name": full_name or username or email,
|
|
"realm_access": {"roles": ["local_dev"]},
|
|
}
|
|
return st.session_state["local_mock_profile"]
|