From ef54f8fe8fd5cf16f00fe2de4ae1b09852b8c9f9 Mon Sep 17 00:00:00 2001
From: johnyrahul <rahul.johny@zipstack.com>
Date: Mon, 11 Mar 2024 09:51:26 +0530
Subject: [PATCH] Renaming and removal unused constants

---
 backend/account/authentication_controller.py | 32 ++++++++++----------
 backend/account/constants.py                 | 11 +------
 2 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/backend/account/authentication_controller.py b/backend/account/authentication_controller.py
index 1fa40f998a..f434a6a03a 100644
--- a/backend/account/authentication_controller.py
+++ b/backend/account/authentication_controller.py
@@ -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,
@@ -105,13 +105,13 @@ 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)}"
                 )
@@ -119,10 +119,10 @@ def authorization_callback(
             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:
@@ -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
@@ -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(
@@ -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)
diff --git a/backend/account/constants.py b/backend/account/constants.py
index f962f0bfaf..69197e19dc 100644
--- a/backend/account/constants.py
+++ b/backend/account/constants.py
@@ -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"
@@ -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."""
 
