mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-02 07:00:51 -04:00
Fix 500s when requesting json after logged out:
* Update permissions decorator to make sure user is logged in first, else 401 * Stop further ajax json calls on failure
This commit is contained in:
15
app/utils.py
15
app/utils.py
@@ -42,11 +42,18 @@ def user_has_permissions(*permissions, admin_override=False, any_=False):
|
||||
@wraps(func)
|
||||
def wrap_func(*args, **kwargs):
|
||||
from flask_login import current_user
|
||||
if current_user and current_user.has_permissions(permissions=permissions,
|
||||
admin_override=admin_override, any_=any_):
|
||||
return func(*args, **kwargs)
|
||||
|
||||
if current_user and current_user.is_authenticated:
|
||||
if current_user.has_permissions(
|
||||
permissions=permissions,
|
||||
admin_override=admin_override,
|
||||
any_=any_
|
||||
):
|
||||
return func(*args, **kwargs)
|
||||
else:
|
||||
abort(403)
|
||||
else:
|
||||
abort(403)
|
||||
abort(401)
|
||||
return wrap_func
|
||||
return wrap
|
||||
|
||||
|
||||
Reference in New Issue
Block a user