Commit 87ff0107 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Raise one by one instead of if checks

parent 347ee6cc
...@@ -76,16 +76,11 @@ module Gitlab ...@@ -76,16 +76,11 @@ module Gitlab
end end
def validate_permission(author, project, permission) def validate_permission(author, project, permission)
if author raise UserNotFoundError unless author
if author.blocked? raise UserBlockedError if author.blocked?
raise UserBlockedError # TODO: Give project not found error if author cannot read project
elsif project.nil? || !author.can?(permission, project) raise UserNotAuthorizedError if project.nil? ||
# TODO: Give project not found error if author cannot read project !author.can?(permission, project)
raise UserNotAuthorizedError
end
else
raise UserNotFoundError
end
end end
# Find the first matched user in database from email From: section # Find the first matched user in database from email From: section
......
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