language models updated

This commit is contained in:
2025-01-27 13:00:21 +03:00
parent bc300f727a
commit e403993d24
9 changed files with 124 additions and 123 deletions

View File

@@ -46,6 +46,7 @@ AuthenticationLoginEventMethods = MethodToEvent(
description="Login to the system via domain, access key : [email] | [phone]",
)
def authentication_login_with_domain_and_creds_endpoint(
request: Request,
data: EndpointBaseRequestModel,
@@ -78,11 +79,12 @@ def authentication_select_company_or_occupant_type(
"""
Select company or occupant type.
"""
auth_dict = authentication_select_company_or_occupant_type.auth
auth_context = authentication_select_company_or_occupant_type.auth_context
function = AuthenticationSelectEventMethods.retrieve_event(
event_function_code=f"{authentication_select_company_or_occupant_type_super_user_event.key}"
)
return function.endpoint_callable(request=request, data=data, token_dict=auth_dict)
function.endpoint_callable.auth_context = auth_context
return function.endpoint_callable(request=request, data=data)
AuthenticationSelectEventMethods.endpoint_callable = authentication_select_company_or_occupant_type

View File

@@ -22,6 +22,7 @@ from ApiLayers.Schemas import (
OccupantTypes,
Users,
)
from ApiLayers.ApiValidations.Response.default_response import EndpointSuccessResponse
from fastapi import Request
@@ -50,17 +51,28 @@ def authentication_login_with_domain_and_creds(request: Request, data: Any):
token = user_login_module.login_user_via_credentials(access_data=data)
# Return response with token and headers
return {
"completed": True,
"message": "User is logged in successfully",
"access_token": token.get("access_token"),
"refresh_token": token.get("refresher_token"),
"access_object": {
"user_type": token.get("user_type"),
"companies_list": token.get("companies_list"),
},
"user": token.get("user"),
}
user_login_module.language = "tr"
success_response = EndpointSuccessResponse(
code="LoginSuccess", lang=user_login_module.language
)
return success_response.as_dict(
data={
"access_token": token.get("access_token"),
"refresh_token": token.get("refresher_token"),
"access_object": {"user_type": token.get("user_type"), "companies_list": token.get("companies_list")},
"user": token.get("user"),
}
)
# return {
# "completed": True,
# "message": "User is logged in successfully",
# "access_token": token.get("access_token"),
# "refresh_token": token.get("refresher_token"),
# "access_object": {
# "user_type": token.get("user_type"), "companies_list": token.get("companies_list")
# },
# "user": token.get("user"),
# }
def handle_employee_selection(request: Request, data: Any, token_dict: TokenDictType):
@@ -261,16 +273,15 @@ def handle_occupant_selection(request: Request, data: Any, token_dict: TokenDict
)
def authentication_select_company_or_occupant_type(request: Request, data: Any, token_dict: TokenDictType):
def authentication_select_company_or_occupant_type(request: Request, data: Any):
"""Handle selection of company or occupant type"""
token_dict: TokenDictType = authentication_select_company_or_occupant_type.auth_context
if token_dict.is_employee:
if handle_employee_selection(data, token_dict, request):
return {"selected_occupant": None, "selected_company": data.company_uu_id}
elif token_dict.is_occupant:
if handle_occupant_selection(data, token_dict, request):
return {
"selected_company": None, "selected_occupant": data.build_living_space_uu_id,
}
return {"selected_company": None, "selected_occupant": data.build_living_space_uu_id}
return {"completed": False, "selected_company": None, "selected_occupant": None}