From fbbdca01308610813aa7f77deb120e95aed8df6e Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Thu, 28 Oct 2021 12:49:20 +0300 Subject: Redirect to "no_access_page" for pages that need edit and edit-admin --- wqflask/wqflask/decorators.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'wqflask') diff --git a/wqflask/wqflask/decorators.py b/wqflask/wqflask/decorators.py index 1ef8c188..319d9bd4 100644 --- a/wqflask/wqflask/decorators.py +++ b/wqflask/wqflask/decorators.py @@ -1,7 +1,7 @@ """This module contains gn2 decorators""" import redis -from flask import current_app, g, request +from flask import current_app, g, redirect, request, url_for from typing import Dict from urllib.parse import urljoin from functools import wraps @@ -51,7 +51,7 @@ are required""" response = {} if max([DataRole(role) for role in response.get( "data", ["no-access"])]) < DataRole.EDIT: - return "You need to have edit access", 401 + return redirect(url_for("no_access_page")) return f(*args, **kwargs) return wrap @@ -75,6 +75,6 @@ def edit_admins_access_required(f): response = {} if max([AdminRole(role) for role in response.get( "admin", ["not-admin"])]) < AdminRole.EDIT_ADMINS: - return "You need to have edit-admins access", 401 + return redirect(url_for("no_access_page")) return f(*args, **kwargs) return wrap -- cgit v1.2.3