Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions backend/account/authentication_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from account.authentication_service import AuthenticationService
from account.cache_service import CacheService
from account.constants import (
AuthoErrorCode,
AuthorizationErrorCode,
Cookie,
ErrorMessage,
OrganizationMemberModel,
Expand Down Expand Up @@ -105,24 +105,24 @@ def authorization_callback(
except Exception as ex:
"""Error code reference
frontend/src/components/error/GenericError/GenericError.jsx."""
if ex.code == AuthoErrorCode.IDM: # type: ignore
query_params = {"code": AuthoErrorCode.IDM}
if ex.code == AuthorizationErrorCode.IDM: # type: ignore
query_params = {"code": AuthorizationErrorCode.IDM}
return redirect(
f"{settings.ERROR_URL}?{urlencode(query_params)}"
)
elif ex.code == AuthoErrorCode.UMM: # type: ignore
query_params = {"code": AuthoErrorCode.UMM}
elif ex.code == AuthorizationErrorCode.UMM: # type: ignore
query_params = {"code": AuthorizationErrorCode.UMM}
return redirect(
f"{settings.ERROR_URL}?{urlencode(query_params)}"
)

return redirect(f"{settings.ERROR_URL}")

if member.organization_id and member.role and len(member.role) > 0:
organization: Optional[Organization] = (
OrganizationService.get_organization_by_org_id(
member.organization_id
)
organization: Optional[
Organization
] = OrganizationService.get_organization_by_org_id(
member.organization_id
)
if organization:
try:
Expand Down Expand Up @@ -157,7 +157,7 @@ def user_organizations(self, request: Request) -> Any:
except Exception as ex:
#
self.user_logout(request)
if ex.code == AuthoErrorCode.USF: # type: ignore
if ex.code == AuthorizationErrorCode.USF: # type: ignore
response = Response(
status=status.HTTP_412_PRECONDITION_FAILED,
data={"domain": ex.data.get("domain")}, # type: ignore
Expand Down Expand Up @@ -189,9 +189,9 @@ def set_user_organization(
user: User = request.user
organization_ids = CacheService.get_user_organizations(user.user_id)
if not organization_ids:
z_organizations: list[OrganizationData] = (
self.auth_service.get_organizations_by_user_id(user.user_id)
)
z_organizations: list[
OrganizationData
] = self.auth_service.get_organizations_by_user_id(user.user_id)
organization_ids = {org.id for org in z_organizations}
if organization_id and organization_id in organization_ids:
organization = OrganizationService.get_organization_by_org_id(
Expand Down Expand Up @@ -231,9 +231,9 @@ def set_user_organization(
},
)
# Update user session data in redis
user_session_info: dict[str, Any] = (
CacheService.get_user_session_info(user.email)
)
user_session_info: dict[
str, Any
] = CacheService.get_user_session_info(user.email)
user_session_info["current_org"] = organization_id
CacheService.set_user_session_info(user_session_info)
response.set_cookie(Cookie.ORG_ID, organization_id)
Expand Down
11 changes: 1 addition & 10 deletions backend/account/constants.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
class OAuthConstant:
TOKEN_USER_INFO_FEILD = "userinfo"
TOKEN_ORG_ID_FEILD = "org_id"
TOKEN_EMAIL_FEILD = "email"
TOKEN_Z_ID_FEILD = "sub"
TOKEN_USER_NAME_FEILD = "name"
TOKEN_PRIMARY_Z_ID_FEILD = "primary_sub"


class LoginConstant:
INVITATION = "invitation"
ORGANIZATION = "organization"
Expand Down Expand Up @@ -64,7 +55,7 @@ class PluginConfig:
METADATA_IS_ACTIVE = "is_active"


class AuthoErrorCode:
class AuthorizationErrorCode:
"""Error code reference
frontend/src/components/error/GenericError/GenericError.jsx."""

Expand Down