This commit is contained in:
2026-04-07 12:44:06 +05:30
parent 7f81fc64c1
commit 5dd4196014
49 changed files with 2795 additions and 0 deletions

37
app_core/ui/auth_ui.py Normal file
View File

@@ -0,0 +1,37 @@
import re
import streamlit as st
from app_core.services.auth_service import AuthService
def _is_valid_email(value: str) -> bool:
if not value:
return False
pattern = r"^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$"
return re.match(pattern, value.strip()) is not None
def render_auth_card(auth_service: AuthService) -> None:
left, center, right = st.columns([1, 1.2, 1])
with center:
st.markdown('<div class="auth-title">Welcome !!</div>', unsafe_allow_html=True)
st.markdown('<div class="muted" style="margin-bottom:16px;">Sign in to continue</div>', unsafe_allow_html=True)
with st.form("login_form", clear_on_submit=False):
email = st.text_input("Email", placeholder="you@example.com", key="login_email")
password = st.text_input("Password", type="password", placeholder="••••••••", key="login_password")
submitted = st.form_submit_button("Sign in →", use_container_width=True)
if submitted:
if not _is_valid_email(email):
st.error("Enter a valid email address.")
elif not password:
st.error("Password is required.")
else:
ok, user, msg = auth_service.login(email, password)
if ok and user:
st.session_state.auth_user = user
st.success(msg)
st.rerun()
else:
st.error(msg)
st.markdown('</div>', unsafe_allow_html=True)