diff options
author | Francisco Lopez <fjlopez@gitlab.com> | 2017-11-10 13:12:37 +0300 |
---|---|---|
committer | Francisco Lopez <fjlopez@gitlab.com> | 2017-11-17 12:02:11 +0300 |
commit | 2d5397d928cfca222addb250085fe30c72215022 (patch) | |
tree | 28ef7016e52f5ba5696f37a81217987d3dddccfb /lib/gitlab/auth | |
parent | 130a9933fe066598dcc7126acc41cc7a5e63ba8d (diff) |
Removed method handle_return_value
Diffstat (limited to 'lib/gitlab/auth')
-rw-r--r-- | lib/gitlab/auth/user_auth_finders.rb | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/lib/gitlab/auth/user_auth_finders.rb b/lib/gitlab/auth/user_auth_finders.rb index db900908ead..dc688637107 100644 --- a/lib/gitlab/auth/user_auth_finders.rb +++ b/lib/gitlab/auth/user_auth_finders.rb @@ -15,7 +15,7 @@ module Gitlab token = current_request.params[:rss_token].presence return unless token - handle_return_value!(User.find_by_rss_token(token)) + User.find_by_rss_token(token) || raise(API::APIGuard::UnauthorizedError) end def find_user_from_access_token @@ -23,7 +23,7 @@ module Gitlab validate_access_token! - handle_return_value!(access_token.user) + access_token.user || raise(API::APIGuard::UnauthorizedError) end def validate_access_token!(scopes: []) @@ -41,12 +41,6 @@ module Gitlab private - def handle_return_value!(value, &block) - raise API::APIGuard::UnauthorizedError unless value - - block_given? ? yield(value) : value - end - def access_token return @access_token if defined?(@access_token) @@ -63,7 +57,7 @@ module Gitlab return unless token # Expiration, revocation and scopes are verified in `validate_access_token!` - handle_return_value!(PersonalAccessToken.find_by(token: token)) + PersonalAccessToken.find_by(token: token) || raise(API::APIGuard::UnauthorizedError) end def find_oauth_access_token @@ -71,10 +65,11 @@ module Gitlab return unless token # Expiration, revocation and scopes are verified in `validate_access_token!` - handle_return_value!(OauthAccessToken.by_token(token)) do |oauth_token| - oauth_token.revoke_previous_refresh_token! - oauth_token - end + oauth_token = OauthAccessToken.by_token(token) + raise(API::APIGuard::UnauthorizedError) unless oauth_token + + oauth_token.revoke_previous_refresh_token! + oauth_token end # Check if the request is GET/HEAD, or if CSRF token is valid. |