Skip to content

LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows

Handling USR ( user signup restrict ) error code (#242)

Siddhiq07baecd9d131
diff --git a/backend/account/authentication_controller.py b/backend/account/authentication_controller.py
index 48fa8afdb..cb1bd2ed1 100644
--- a/backend/account/authentication_controller.py
+++ b/backend/account/authentication_controller.py
@@ -147,13 +147,13 @@ class AuthenticationController:
except Exception as ex:
#
self.user_logout(request)
- if (
- hasattr(ex, "code")
- and ex.code == AuthorizationErrorCode.USF # type: ignore
- ):
+ if hasattr(ex, "code") and ex.code in {
+ AuthorizationErrorCode.USF,
+ AuthorizationErrorCode.USR,
+ }: # type: ignore
response = Response(
status=status.HTTP_412_PRECONDITION_FAILED,
- data={"domain": ex.data.get("domain")}, # type: ignore
+ data={"domain": ex.data.get("domain"), "code": ex.code},
)
return response
user: User = request.user
diff --git a/backend/account/constants.py b/backend/account/constants.py
index a88fb69c3..fe784a89f 100644
--- a/backend/account/constants.py
+++ b/backend/account/constants.py
@@ -74,3 +74,4 @@ class AuthorizationErrorCode:
UMM = "UMM"
INF = "INF"
USF = "USF"
+ USR = "USR"
diff --git a/frontend/src/components/error/GenericError/GenericError.jsx b/frontend/src/components/error/GenericError/GenericError.jsx
index 52e748fb0..a05f0de4c 100644
--- a/frontend/src/components/error/GenericError/GenericError.jsx
+++ b/frontend/src/components/error/GenericError/GenericError.jsx
@@ -30,6 +30,11 @@ function GenericError() {
subtitle:
"You'll need to contact the admin of your organization's account to get access or you'll need to use a different email address to sign up.",
},
+ USR: {
+ title: `Sign-up not allowed.`,
+ subtitle:
+ "You'll need to contact the admin of your organization's account to get access.",
+ },
// Add more key-value pairs as needed
};
diff --git a/frontend/src/hooks/useSessionValid.js b/frontend/src/hooks/useSessionValid.js
index 30116f28b..d25cdde76 100644
--- a/frontend/src/hooks/useSessionValid.js
+++ b/frontend/src/hooks/useSessionValid.js
@@ -113,8 +113,10 @@ function useSessionValid() {
}
if (err.request?.status === 412) {
- const domainName = JSON.parse(err.request.response).domain;
- window.location.href = `/error?code=USF&domain=${domainName}`;
+ const response = JSON.parse(err.request.response);
+ const domainName = response.domain;
+ const code = response.code;
+ window.location.href = `/error?code=${code}&domain=${domainName}`;
// May be need a logout button there or auto logout
}
}