Class: Devise::Passwordless::SignedGlobalIDTokenizer
- Inherits:
-
Object
- Object
- Devise::Passwordless::SignedGlobalIDTokenizer
- Defined in:
- lib/devise/passwordless/tokenizers/signed_global_id_tokenizer.rb
Class Method Summary collapse
- .decode(token, resource_class) ⇒ Object
- .encode(resource, expires_in: nil, expires_at: nil) ⇒ Object
Class Method Details
.decode(token, resource_class) ⇒ Object
13 14 15 16 17 18 |
# File 'lib/devise/passwordless/tokenizers/signed_global_id_tokenizer.rb', line 13 def self.decode(token, resource_class) resource = GlobalID::Locator.locate_signed(token, for: "login") raise ExpiredTokenError unless resource raise InvalidTokenError if resource.class != resource_class [resource, {}] end |
.encode(resource, expires_in: nil, expires_at: nil) ⇒ Object
5 6 7 8 9 10 11 |
# File 'lib/devise/passwordless/tokenizers/signed_global_id_tokenizer.rb', line 5 def self.encode(resource, expires_in: nil, expires_at: nil) if expires_at resource.to_sgid(expires_at: expires_at, for: "login").to_s else resource.to_sgid(expires_in: expires_in || resource.class.passwordless_login_within, for: "login").to_s end end |