from backend.application.signin_hub import SignInHub from pydantic import BaseModel from fastapi import APIRouter from fastapi.encoders import jsonable_encoder from fastapi.responses import JSONResponse router = APIRouter() # Web API # try_signin_with_email # class UserSignWithEmailBody(BaseModel): email: str host: str class UserSignWithEmailResponse(BaseModel): signin_type: int @router.post( "/try-signin-with-email", operation_id="user-try-signin-with-email", summary="try to signin with email", description="A client user is trying to sign in with their email. \ The system will determine to send an authentication code to the email \ or let the uesr use their FLID and passward to sign in", response_description="signin_type:0 meaning simplified(using email) signin, \ 1 meaning standard(using FLID and passward) signin", ) async def try_signin_with_email( item: UserSignWithEmailBody, ): result = await SignInHub().try_signin_with_email(item.email, item.host) result = {"signin_type": result} return JSONResponse(content=jsonable_encoder(result))