feat(backend/auth): added otk response model
This commit is contained in:
@@ -210,3 +210,10 @@ class AccessResponse(BaseModel):
|
||||
refresh_token: RefreshToken = Field(
|
||||
description="The refresh token issued alongside the access token for obtaining new access tokens."
|
||||
)
|
||||
|
||||
|
||||
class OtkResponse(BaseModel):
|
||||
status: str = Field(description="The status of the one-time code (OTC) request.")
|
||||
account_id: uuid.UUID = Field(
|
||||
description="The unique identifier of the account for which the OTC was requested."
|
||||
)
|
||||
|
||||
@@ -14,6 +14,7 @@ from inse.auth.model import (
|
||||
AccessToken,
|
||||
IdToken,
|
||||
LoginResponse,
|
||||
OtkResponse,
|
||||
RefreshToken,
|
||||
)
|
||||
|
||||
@@ -40,7 +41,7 @@ async def request_otk(
|
||||
session: SessionDep,
|
||||
email: Annotated[str, Body(description="User's email address")],
|
||||
password: Annotated[str, Body(description="User's password")],
|
||||
):
|
||||
) -> OtkResponse:
|
||||
return auth_service.request_otk(session=session, email=email, password=password)
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ from inse.auth.model import (
|
||||
IdToken,
|
||||
LoginResponse,
|
||||
Organization,
|
||||
OtkResponse,
|
||||
RefreshToken,
|
||||
Secret,
|
||||
TokenType,
|
||||
@@ -155,7 +156,7 @@ def _verify_password(password: str, password_hash: str) -> bool:
|
||||
return False
|
||||
|
||||
|
||||
def request_otk(session: Session, email: str, password: str):
|
||||
def request_otk(session: Session, email: str, password: str) -> OtkResponse:
|
||||
"""Requests a one-time key (OTK) for authentication using email and password. Validates the provided credentials and generates a one-time key if valid.
|
||||
|
||||
Args:
|
||||
@@ -236,7 +237,7 @@ def request_otk(session: Session, email: str, password: str):
|
||||
else:
|
||||
logger.info("OTK generated for account %s", account.id)
|
||||
|
||||
return {"status": "ok", "account_id": str(account.id)}
|
||||
return OtkResponse(status="success", account_id=account.id)
|
||||
|
||||
|
||||
def login(
|
||||
|
||||
Reference in New Issue
Block a user