class Devise::Strategies::MagicLinkAuthenticatable
Attributes
token[RW]
undef :password undef :password=
Public Instance Methods
authenticate!()
click to toggle source
# File lib/devise/strategies/magic_link_authenticatable.rb, line 22 def authenticate! begin data = decode_passwordless_token rescue Devise::Passwordless::LoginToken::InvalidOrExpiredTokenError fail!(:magic_link_invalid) return end resource = mapping.to.find_by(id: data["data"]["resource"]["key"]) if resource && Devise.passwordless_expire_old_tokens_on_sign_in if (last_login = resource.try(:current_sign_in_at)) token_created_at = ActiveSupport::TimeZone["UTC"].at(data["created_at"]) if token_created_at < last_login fail!(:magic_link_invalid) return end end end if validate(resource) remember_me(resource) resource.after_magic_link_authentication success!(resource) else fail!(:magic_link_invalid) end end
valid_for_http_auth?()
click to toggle source
Calls superclass method
# File lib/devise/strategies/magic_link_authenticatable.rb, line 14 def valid_for_http_auth? super && http_auth_hash[:token].present? end
valid_for_params_auth?()
click to toggle source
Calls superclass method
# File lib/devise/strategies/magic_link_authenticatable.rb, line 18 def valid_for_params_auth? super && params_auth_hash[:token].present? end
Private Instance Methods
decode_passwordless_token()
click to toggle source
# File lib/devise/strategies/magic_link_authenticatable.rb, line 53 def decode_passwordless_token Devise::Passwordless::LoginToken.decode(self.token) end
with_authentication_hash(auth_type, auth_values)
click to toggle source
Sets the authentication hash and the token from params_auth_hash or http_auth_hash.
# File lib/devise/strategies/magic_link_authenticatable.rb, line 58 def with_authentication_hash(auth_type, auth_values) self.authentication_hash, self.authentication_type = {}, auth_type self.token = auth_values[:token] parse_authentication_key_values(auth_values, authentication_keys) && parse_authentication_key_values(request_values, request_keys) end