Web service initiated

This commit is contained in:
2025-04-05 14:59:10 +03:00
parent b1c8203a33
commit fa4df11323
76 changed files with 5385 additions and 171 deletions

View File

@@ -13,13 +13,12 @@ from ApiServices.AuthService.validations.request.authentication.login_post impor
RequestChangePassword,
RequestForgotPasswordPhone,
RequestForgotPasswordEmail,
RequestVerifyOTP,
)
from ApiServices.AuthService.events.auth.auth import AuthHandlers
auth_route = APIRouter(
prefix="/authentication",
tags=["Authentication Cluster"],
)
auth_route = APIRouter(prefix="/authentication", tags=["Authentication Cluster"])
@auth_route.post(
@@ -49,8 +48,12 @@ def authentication_login_post(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
headers=headers,
)
result = AuthHandlers.LoginHandler.authentication_login_with_domain_and_creds(
request=request,
data=data,
)
return JSONResponse(
content={**data.model_dump()},
content=result,
status_code=status.HTTP_202_ACCEPTED,
headers=headers,
)
@@ -84,9 +87,12 @@ def authentication_select_post(
status_code=status.HTTP_406_NOT_ACCEPTABLE,
headers=headers,
)
result = AuthHandlers.LoginHandler.authentication_select_company_or_occupant_type(
request=request,
data=data,
)
return JSONResponse(
content=data.model_dump(),
content=result,
status_code=status.HTTP_202_ACCEPTED,
headers=headers,
)
@@ -107,13 +113,15 @@ def authentication_password_create_post(
"""
Authentication create password Route with Post Method
"""
token = request.headers.get(api_config.ACCESS_TOKEN_TAG, None)
headers = {
"language": language or "",
"domain": domain or "",
"eys-ext": f"{str(uuid.uuid4())}",
"token": token,
}
result = AuthHandlers.PasswordHandler.create_password(
password=data.password,
password_token=data.password_token,
)
if not domain or not language:
return JSONResponse(
content={"error": "EYS_0001"},
@@ -121,7 +129,7 @@ def authentication_password_create_post(
headers=headers,
)
return JSONResponse(
content={**data.model_dump()},
content={},
status_code=status.HTTP_202_ACCEPTED,
headers=headers,
)
@@ -333,3 +341,41 @@ def authentication_token_refresh_post(
status_code=status.HTTP_202_ACCEPTED,
headers=headers,
)
@auth_route.get(
path="/password/verify-otp",
summary="Verify OTP for password reset",
description="Verify OTP for password reset",
)
def authentication_password_verify_otp(
request: Request,
data: RequestVerifyOTP,
language: str = Header(None, alias="language"),
domain: str = Header(None, alias="domain"),
tz: str = Header(None, alias="timezone"),
):
"""
Verify OTP for password reset
"""
token = request.headers.get(api_config.ACCESS_TOKEN_TAG, None)
headers = {
"language": language or "",
"domain": domain or "",
"eys-ext": f"{str(uuid.uuid4())}",
"tz": tz or "GMT+3",
"token": token,
}
print('Token&OTP : ', data.otp, data.token)
if not domain or not language:
return JSONResponse(
content={"error": "EYS_0003"},
status_code=status.HTTP_406_NOT_ACCEPTABLE,
headers=headers,
)
return JSONResponse(
content={},
status_code=status.HTTP_202_ACCEPTED,
headers=headers,
)