Class: AuthRails::Strategies::BaseStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/auth_rails/strategies/base_strategy.rb

Direct Known Subclasses

AllowedTokenStrategy

Class Method Summary collapse

Class Method Details

.gen_token(payload:, exp: nil, secret_key: nil, algorithm: nil, jti: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'lib/auth_rails/strategies/base_strategy.rb', line 14

def gen_token(payload:, exp: nil, secret_key: nil, algorithm: nil, jti: nil, **)
  Services::JwtService.gen_token(
    exp: exp,
    jti: jti,
    payload: payload,
    algorithm: algorithm,
    secret_key: secret_key
  )
end

.retrieve_resource(payload:) ⇒ Object



7
8
9
10
11
12
# File 'lib/auth_rails/strategies/base_strategy.rb', line 7

def retrieve_resource(payload:)
  symbolized_payload = payload.symbolize_keys

  AuthRails.resource_class
           .find_by(AuthRails.identifier_name => symbolized_payload[:sub])
end