app/api/concerns/api_guard.rb
# Invokes the doorkeeper guard.
#
# If token string is blank, then it raises MissingTokenError.
#
# If token is presented and valid, then it sets @current_user.
#
# If the token does not have sufficient scopes to cover the requred scopes,
# then it raises InsufficientScopeError.
#
# If the token is expired, then it raises ExpiredError.
#
# If the token is revoked, then it raises RevokedError.
#
# If the token is not found (nil), then it raises TokenNotFoundError.
#
# Arguments:
#
#   scopes: (optional) scopes required for this guard.
#           Defaults to empty array.
#
Invokes the doorkeeper guard.
If token string is blank, then it raises MissingTokenError.

If token is presented and valid, then it sets @current_user.

If the token does not have sufficient scopes to cover the requred scopes,
then it raises InsufficientScopeError.

If the token is expired, then it raises ExpiredError.

If the token is revoked, then it raises RevokedError.

If the token is not found (nil), then it raises TokenNotFoundError.



(optional) scopes required for this guard.
Defaults to empty array.
Invokes the doorkeeper guard . If token string is blank then it raises MissingTokenError . If token is presented and valid then it sets @current_user . If the token does not have sufficient scopes to cover the requred scopes then it raises InsufficientScopeError . If the token is expired then it raises ExpiredError . If the token is revoked then it raises RevokedError . If the token is not found ( nil ) then it raises TokenNotFoundError . ( optional ) scopes required for this guard . Defaults to empty array .
def guard!(scopes: [])
      token_string = get_token_string()
      if token_string.blank?
        raise MissingTokenError
      elsif (access_token = find_access_token(token_string)).nil?
        raise TokenNotFoundError
      else
        case validate_access_token(access_token, scopes)
        when Oauth2::AccessTokenValidationService::INSUFFICIENT_SCOPE
          raise InsufficientScopeError.new(scopes)
        when Oauth2::AccessTokenValidationService::EXPIRED
          raise ExpiredError
        when Oauth2::AccessTokenValidationService::REVOKED
          raise RevokedError
        when Oauth2::AccessTokenValidationService::VALID
          @current_user = User.find(access_token.resource_owner_id)
        end
      end
    end
def guard! ( scopes : [ ] ) token_string = get_token_string ( ) if token_string . blank? raise MissingTokenError elsif ( access_token = find_access_token ( token_string ) ) . nil? raise TokenNotFoundError else case validate_access_token ( access_token , scopes ) when Oauth2 :: AccessTokenValidationService :: INSUFFICIENT_SCOPE raise InsufficientScopeError . new ( scopes ) when Oauth2 :: AccessTokenValidationService :: EXPIRED raise ExpiredError when Oauth2 :: AccessTokenValidationService :: REVOKED raise RevokedError when Oauth2 :: AccessTokenValidationService :: VALID @current_user = User . find ( access_token . resource_owner_id ) end end end
Invokes the doorkeeper guard.
Invokes the doorkeeper guard .
scopes
<not_specific>