aboutsummaryrefslogtreecommitdiff
path: root/gn_auth/auth/authorisation/users/admin
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2024-02-28 11:55:15 +0300
committerFrederick Muriuki Muriithi2024-02-28 11:55:15 +0300
commit314a095264f47b8aecfc01d20beca4f35ab9121a (patch)
tree7a0899d018bff9161b55cf5042fadd44e9bfdd82 /gn_auth/auth/authorisation/users/admin
parent2716b567ef6f48db8ce980e140a895aa3d18a293 (diff)
downloadgn-auth-314a095264f47b8aecfc01d20beca4f35ab9121a.tar.gz
Handle the "NotFoundError" exception at the route level
Handle the "NotFoundError" exception at the route level, since if we do not, the application level handler takes over and simply returns a JSON response with the details of the failure.
Diffstat (limited to 'gn_auth/auth/authorisation/users/admin')
-rw-r--r--gn_auth/auth/authorisation/users/admin/views.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/gn_auth/auth/authorisation/users/admin/views.py b/gn_auth/auth/authorisation/users/admin/views.py
index 6ace0e5..aed8b31 100644
--- a/gn_auth/auth/authorisation/users/admin/views.py
+++ b/gn_auth/auth/authorisation/users/admin/views.py
@@ -18,6 +18,8 @@ from flask import (
from gn_auth import session
+from gn_auth.auth.authorisation.errors import NotFoundError
+
from ....db import sqlite3 as db
from ....db.sqlite3 import with_db_connection
@@ -77,8 +79,10 @@ def login():
expires=(
datetime.now(tz=timezone.utc) + timedelta(minutes=10)))
return redirect(url_for(next_uri))
- flash(error_message, "alert-danger")
- return login_page
+ raise NotFoundError(error_message)
+ except NotFoundError as _nfe:
+ flash(error_message, "alert-danger")
+ return login_page
except EmailNotValidError as _enve:
flash(error_message, "alert-danger")
return login_page