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
end
def validate_permission(author, project, permission)
if author
if author.blocked?
raise UserBlockedError
elsif project.nil? || !author.can?(permission, project)
# TODO: Give project not found error if author cannot read project
raise UserNotAuthorizedError
end
else
raise UserNotFoundError
end
raise UserNotFoundError unless author
raise UserBlockedError if author.blocked?
# TODO: Give project not found error if author cannot read project
raise UserNotAuthorizedError if project.nil? ||
!author.can?(permission, project)
end
# 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