From c35e2507e171864475bff7b0713e6d7604bdb1fb Mon Sep 17 00:00:00 2001 From: Mo8it Date: Mon, 19 Sep 2022 15:20:18 +0200 Subject: [PATCH] Add inaccessible_callback to BaseView --- advlabdb/custom_classes.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/advlabdb/custom_classes.py b/advlabdb/custom_classes.py index ff35de4..fec7336 100644 --- a/advlabdb/custom_classes.py +++ b/advlabdb/custom_classes.py @@ -339,7 +339,13 @@ class SecureAssistantModelView(CustomModelView): return super().get_details_columns() -class SecureAdminBaseView(BaseView): +class CustomBaseView(BaseView): + def inaccessible_callback(self, name, **kwargs): + # Redirect to login page if user doesn't have access + return redirect(url_for("security.login", next=request.url)) + + +class SecureAdminBaseView(CustomBaseView): def __init__(self, **kwargs): url = get_url(kwargs) super().__init__(endpoint="admin_" + url, **kwargs) @@ -348,7 +354,7 @@ class SecureAdminBaseView(BaseView): return adminViewIsAccessible() -class SecureAssistantBaseView(BaseView): +class SecureAssistantBaseView(CustomBaseView): def __init__(self, **kwargs): url = get_url(kwargs) super().__init__(endpoint="assistant_" + url, **kwargs)