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('
Welcome !!
', unsafe_allow_html=True) st.markdown('
Sign in to continue
', 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('', unsafe_allow_html=True)