Add folder permission check to copy template endpoint

Copying a template from another service is one place where we can't
use the `current_service` method since the source template can belong
to a different service the user has access to, so we're using an API
client method.
This commit is contained in:
Alexey Bezhan
2019-03-20 16:41:01 +00:00
parent 35fb92c02c
commit 792b625de7
2 changed files with 20 additions and 0 deletions

View File

@@ -379,6 +379,13 @@ def copy_template(service_id, template_id):
str(template_id),
)['data']
template_folder = template_folder_api_client.get_template_folder(service_id, template['folder'])
if (
current_service.has_permission('edit_folder_permissions') and
not current_user.has_template_folder_permission(template_folder)
):
abort(403)
if request.method == 'POST':
return add_service_template(service_id, template['template_type'])