Skip to content

Commit

Permalink
added log and raise exeception in domain validation (#277)
Browse files Browse the repository at this point in the history
* added log and raise exeception in domain validation

* added error codes for invalid email address and disposible email

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Neha <115609453+nehabagdia@users.noreply.github.com>
  • Loading branch information
3 people committed May 3, 2024
1 parent e28fd03 commit a0e052b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions backend/account/authentication_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def user_organizations(self, request: Request) -> Any:
if hasattr(ex, "code") and ex.code in {
AuthorizationErrorCode.USF,
AuthorizationErrorCode.USR,
AuthorizationErrorCode.INE001,
AuthorizationErrorCode.INE002,
}: # type: ignore
response = Response(
status=status.HTTP_412_PRECONDITION_FAILED,
Expand Down
5 changes: 5 additions & 0 deletions backend/account/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class AuthorizationErrorCode:
INF: INVITATION NOT FOUND (Invitation is either invalid or has expired)
UMM: USER MEMBERSHIP MISCONDUCT
USF: USER FOUND (User Account Already Exists for Organization)
INE001: INVALID EMAIL Exception code when an invalid email address is used
like disposable.
INE002: INVALID EMAIL Exception code when an invalid email address format.
Error code reference :
frontend/src/components/error/GenericError/GenericError.jsx.
Expand All @@ -82,3 +85,5 @@ class AuthorizationErrorCode:
INF = "INF"
USF = "USF"
USR = "USR"
INE001 = "INE001"
INE002 = "INE002"
8 changes: 8 additions & 0 deletions frontend/src/components/error/GenericError/GenericError.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ function GenericError() {
subtitle:
"You'll need to contact the admin of your organization's account to get access.",
},
INE001: {
title: `Email not allowed`,
subtitle: "Disposible emails not allowed.",
},
INE002: {
title: `Invalid Email format`,
subtitle: "Please give a valid email address",
},

// Add more key-value pairs as needed
};
Expand Down

0 comments on commit a0e052b

Please sign in to comment.