diff --git a/ApiServices/AuthService/endpoints/auth/route.py b/ApiServices/AuthService/endpoints/auth/route.py index 4cdac00..067aa54 100644 --- a/ApiServices/AuthService/endpoints/auth/route.py +++ b/ApiServices/AuthService/endpoints/auth/route.py @@ -8,7 +8,7 @@ from ApiServices.AuthService.config import api_config from ApiServices.AuthService.validations.request.authentication.login_post import ( RequestLogin, RequestSelectLiving, - RequestSelectOccupant, + RequestSelectEmployee, RequestCreatePassword, RequestChangePassword, RequestForgotPasswordPhone, @@ -67,7 +67,7 @@ def authentication_login_post( ) def authentication_select_post( request: Request, - data: Union[RequestSelectOccupant, RequestSelectLiving], + data: Union[RequestSelectEmployee, RequestSelectLiving], language: str = Header(None, alias="language"), domain: str = Header(None, alias="domain"), tz: str = Header(None, alias="timezone"), diff --git a/ApiServices/AuthService/validations/request/authentication/login_post.py b/ApiServices/AuthService/validations/request/authentication/login_post.py index 838111c..fb74b9c 100644 --- a/ApiServices/AuthService/validations/request/authentication/login_post.py +++ b/ApiServices/AuthService/validations/request/authentication/login_post.py @@ -18,7 +18,7 @@ class RequestApplication(BaseModel): page: str # /building/create -class RequestSelectOccupant(BaseModel): +class RequestSelectEmployee(BaseModel): company_uu_id: str diff --git a/WebServices/client-frontend/src/apicalls/login/login.tsx b/WebServices/client-frontend/src/apicalls/login/login.tsx index 8a889c1..edd0364 100644 --- a/WebServices/client-frontend/src/apicalls/login/login.tsx +++ b/WebServices/client-frontend/src/apicalls/login/login.tsx @@ -24,9 +24,7 @@ interface LoginSelectEmployee { } interface LoginSelectOccupant { - selectedBuilding: any; - build_part_uu_id: string; - occupant_uu_id: string; + build_living_space_uu_id: any; } async function loginViaAccessKeys(payload: LoginViaAccessKeys) { @@ -51,7 +49,7 @@ async function loginViaAccessKeys(payload: LoginViaAccessKeys) { const accessObject = await nextCrypto.encrypt( JSON.stringify({ userType: loginRespone.user_type, - selectionList:loginRespone.selection_list + selectionList: loginRespone.selection_list, }) ); const userProfile = await nextCrypto.encrypt( @@ -122,7 +120,7 @@ async function loginSelectEmployee(payload: LoginSelectEmployee) { "POST", false ); - if (selectResponse.status === 200) { + if (selectResponse.status === 200 || selectResponse.status === 202) { const usersSelection = await nextCrypto.encrypt( JSON.stringify({ company_uu_id: payload.company_uu_id, @@ -139,14 +137,13 @@ async function loginSelectEmployee(payload: LoginSelectEmployee) { } async function loginSelectOccupant(payload: LoginSelectOccupant) { - const selectedBuilding = payload.selectedBuilding; + const build_living_space_uu_id = payload.build_living_space_uu_id; const cookieStore = await cookies(); const nextCrypto = new NextCrypto(tokenSecret); const selectResponse: any = await fetchDataWithToken( loginSelectEndpoint, { - build_part_uu_id: payload.build_part_uu_id, - occupant_uu_id: payload.occupant_uu_id, + build_living_space_uu_id: build_living_space_uu_id, }, "POST", false @@ -155,11 +152,12 @@ async function loginSelectOccupant(payload: LoginSelectOccupant) { if (selectResponse.status === 200) { const usersSelection = await nextCrypto.encrypt( JSON.stringify({ - company_uu_id: { - build_part_uu_id: payload.build_part_uu_id, - occupant_uu_id: payload.occupant_uu_id, - build_id: selectedBuilding, - }, + // company_uu_id: { + // build_part_uu_id: payload.build_part_uu_id, + // occupant_uu_id: payload.occupant_uu_id, + // build_id: selectedBuilding, + // }, + build_living_space_uu_id: build_living_space_uu_id, user_type: "occupant", }) ); diff --git a/WebServices/client-frontend/src/app/(AuthLayout)/auth/select/page.tsx b/WebServices/client-frontend/src/app/(AuthLayout)/auth/select/page.tsx index 34c6dd2..ddc4c78 100644 --- a/WebServices/client-frontend/src/app/(AuthLayout)/auth/select/page.tsx +++ b/WebServices/client-frontend/src/app/(AuthLayout)/auth/select/page.tsx @@ -16,7 +16,7 @@ async function SelectPage() { const selectionList = selection?.selectionList; if (!selectionList || !token_is_valid) { - redirect("/login/email"); + redirect("/auth/login"); } return ( <> diff --git a/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx b/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx new file mode 100644 index 0000000..64c2af0 --- /dev/null +++ b/WebServices/client-frontend/src/app/(AuthLayout)/dashboard/page.tsx @@ -0,0 +1,14 @@ +import React from "react"; +import { checkAccessTokenIsValid } from "@/apicalls/cookies/token"; +import { redirect } from "next/navigation"; + +async function DashboardPage() { + const token_is_valid = await checkAccessTokenIsValid(); + + if (!token_is_valid) { + redirect("/auth/login"); + } + return