Commit 989ddd2b authored by Hayley Swimelar's avatar Hayley Swimelar

Separate method for unauthorized project messages

This commit separates out the logic for handling
unauthorized projects to reduce the complexity of the
authorized_project_find! method.
parent 64fedd20
...@@ -29,12 +29,16 @@ module API ...@@ -29,12 +29,16 @@ module API
project = find_project(id) project = find_project(id)
unless project && can?(current_user, :read_project, project) unless project && can?(current_user, :read_project, project)
return current_user ? not_found! : unauthorized_with_header! return unauthorized_project_message
end end
project project
end end
def unauthorized_project_message
current_user ? not_found! : unauthorized_with_header!
end
def unauthorized_with_header! def unauthorized_with_header!
header(AUTHENTICATE_REALM_HEADER, AUTHENTICATE_REALM_NAME) header(AUTHENTICATE_REALM_HEADER, AUTHENTICATE_REALM_NAME)
unauthorized! unauthorized!
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment