Have permissions decorators check user signed in

Rather than force us to write the decorators in a specific order let’s
just have one decorator call the other. This should make fewer lines of
code, and fewer annoying test failures. It also means that the same way
of raising a `401` (through the `current_app` method) is used
everywhere.
This commit is contained in:
Chris Hill-Scott
2019-07-01 15:22:08 +01:00
parent 3da9e84ece
commit b620b677d3
24 changed files with 117 additions and 267 deletions

View File

@@ -1,5 +1,5 @@
from flask import flash, redirect, render_template, request, url_for
from flask_login import current_user, login_required
from flask_login import current_user
from app import user_api_client
from app.event_handlers import create_archive_user_event
@@ -10,7 +10,6 @@ from app.utils import user_is_platform_admin
@main.route("/find-users-by-email", methods=['GET', 'POST'])
@login_required
@user_is_platform_admin
def find_users_by_email():
form = SearchUsersByEmailForm()
@@ -28,7 +27,6 @@ def find_users_by_email():
@main.route("/users/<user_id>", methods=['GET'])
@login_required
@user_is_platform_admin
def user_information(user_id):
return render_template(
@@ -38,7 +36,6 @@ def user_information(user_id):
@main.route("/users/<uuid:user_id>/archive", methods=['GET', 'POST'])
@login_required
@user_is_platform_admin
def archive_user(user_id):
if request.method == 'POST':