diff options
Diffstat (limited to 'lib/gitlab/auth/user_auth_finders.rb')
-rw-r--r-- | lib/gitlab/auth/user_auth_finders.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb index 93f3cae0a95..86f1c13d4b8 100644 --- a/lib/gitlab/auth/user_auth_finders.rb +++ b/lib/gitlab/auth/user_auth_finders.rb @@ -29,7 +29,9 @@ module Gitlab private def handle_return_value!(value, &block) - return unless value + unless value + raise_unauthorized_error? ? raise_unauthorized_error! : return + end block_given? ? yield(value) : value end @@ -75,6 +77,18 @@ module Gitlab ActionDispatch::Request.new(request.env) end + + def raise_unauthorized_error? + defined?(@raise_unauthorized_error) ? @raise_unauthorized_error : false + end + + def set_raise_unauthorized_error + @raise_unauthorized_error = true + end + + def raise_unauthorized_error! + raise API::APIGuard::UnauthorizedError + end end end end |