Class: SolidusJwt::DeviseStrategies::RefreshToken

Inherits:
Base
  • Object
show all
Defined in:
lib/solidus_jwt/devise_strategies/refresh_token.rb

Instance Method Summary collapse

Methods inherited from Base

#valid?

Instance Method Details

#authenticate!Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/solidus_jwt/devise_strategies/refresh_token.rb', line 6

def authenticate!
  return fail!(:invalid) if resource.nil? || resource.user.nil?

  block = proc do
    # If we honor then mark the refresh token as stale for one time use
    # rubocop:disable Rails/SkipsModelValidations
    resource.honor? && resource.update_columns(active: false)
    # rubocop:enable Rails/SkipsModelValidations
  end

  if resource.user.valid_for_authentication?(&block)
    return success!(resource.user)
  end

  fail!(:invalid)
end