fix: Arity of WebUserAuthorizer#get_credentials should be compatible with base class

This commit is contained in:
Daniel Azuma 2019-07-26 08:19:06 -07:00 committed by GitHub
parent b9531ea662
commit c5e5f55bfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -14,3 +14,5 @@ Metrics/ModuleLength:
Metrics/BlockLength: Metrics/BlockLength:
Exclude: Exclude:
- "googleauth.gemspec" - "googleauth.gemspec"
Style/SafeNavigation:
Enabled: false

View File

@ -176,12 +176,13 @@ module Google
super options super options
end end
# Fetch stored credentials for the user. # Fetch stored credentials for the user from the given request session.
# #
# @param [String] user_id # @param [String] user_id
# Unique ID of the user for loading/storing credentials. # Unique ID of the user for loading/storing credentials.
# @param [Rack::Request] request # @param [Rack::Request] request
# Current request # Current request. Optional. If omitted, this will attempt to fall back
# on the base class behavior of reading from the token store.
# @param [Array<String>, String] scope # @param [Array<String>, String] scope
# If specified, only returns credentials that have all the \ # If specified, only returns credentials that have all the \
# requested scopes # requested scopes
@ -190,8 +191,8 @@ module Google
# @raise [Signet::AuthorizationError] # @raise [Signet::AuthorizationError]
# May raise an error if an authorization code is present in the session # May raise an error if an authorization code is present in the session
# and exchange of the code fails # and exchange of the code fails
def get_credentials user_id, request, scope = nil def get_credentials user_id, request = nil, scope = nil
if request.session.key? CALLBACK_STATE_KEY if request && request.session.key?(CALLBACK_STATE_KEY)
# Note - in theory, no need to check required scope as this is # Note - in theory, no need to check required scope as this is
# expected to be called immediately after a return from authorization # expected to be called immediately after a return from authorization
state_json = request.session.delete CALLBACK_STATE_KEY state_json = request.session.delete CALLBACK_STATE_KEY