Module: HasJwtToken::Authenticatable
- Defined in:
- lib/has_jwt_token/authenticatable.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
36 37 38 |
# File 'lib/has_jwt_token/authenticatable.rb', line 36 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#authenticate(password) ⇒ Object
40 41 42 43 44 |
# File 'lib/has_jwt_token/authenticatable.rb', line 40 def authenticate(password) super(password).tap do |authenticated| @token = authenticated && encode || nil end end |
#encode ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/has_jwt_token/authenticatable.rb', line 46 def encode HasJwtToken::JwtProxy.encode( algorithm: algorithm, payload: model_payload.merge(claims_payload), secret: secret, header_fields: header_fields ) end |