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 jsonify, redirect, render_template, session, url_for
from flask_login import current_user, login_required
from flask_login import current_user
from notifications_python_client.errors import HTTPError
from notifications_utils.recipients import format_phone_number_human_readable
from notifications_utils.template import SMSPreviewTemplate
@@ -13,7 +13,6 @@ from app.utils import user_has_permissions
@main.route("/services/<service_id>/conversation/<notification_id>")
@user_has_permissions('view_activity')
@login_required
def conversation(service_id, notification_id):
user_number = get_user_number(service_id, notification_id)
@@ -29,7 +28,6 @@ def conversation(service_id, notification_id):
@main.route("/services/<service_id>/conversation/<notification_id>.json")
@user_has_permissions('view_activity')
@login_required
def conversation_updates(service_id, notification_id):
return jsonify(get_conversation_partials(
@@ -41,7 +39,6 @@ def conversation_updates(service_id, notification_id):
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with")
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with/from-folder/<uuid:from_folder>")
@user_has_permissions('send_messages')
@login_required
def conversation_reply(
service_id,
notification_id,
@@ -64,7 +61,6 @@ def conversation_reply(
@main.route("/services/<service_id>/conversation/<notification_id>/reply-with/<template_id>")
@user_has_permissions('send_messages')
@login_required
def conversation_reply_with_template(
service_id,
notification_id,