Module: Devise::Models::MagicLinkAuthenticatable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/devise/models/magic_link_authenticatable.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#active_for_magic_link_authentication? ⇒ Boolean
Set this to false to disable magic link auth for this model instance.
-
#after_magic_link_authentication ⇒ Object
A callback initiated after successfully authenticating.
- #encode_passwordless_token(*args, **kwargs) ⇒ Object
-
#magic_link_inactive_message ⇒ Object
This method determines which error message to display when magic link auth is disabled for this model instance.
-
#password ⇒ Object
Not having a #password method breaks the :validatable module.
- #password_required? ⇒ Boolean
- #send_magic_link(remember_me: false, **kwargs) ⇒ Object
Instance Method Details
#active_for_magic_link_authentication? ⇒ Boolean
Set this to false to disable magic link auth for this model instance. Magic links will still be generated by the sign-in page, but visiting them will instead display an error message.
57 58 59 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 57 def active_for_magic_link_authentication? true end |
#after_magic_link_authentication ⇒ Object
A callback initiated after successfully authenticating. This can be used to insert your own logic that is only run after the user successfully authenticates.
Example:
def after_magic_link_authentication
self.update_attribute(:invite_code, nil)
end
51 52 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 51 def after_magic_link_authentication end |
#encode_passwordless_token(*args, **kwargs) ⇒ Object
32 33 34 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 32 def encode_passwordless_token(*args, **kwargs) self.class.passwordless_tokenizer_class.encode(self, *args, **kwargs) end |
#magic_link_inactive_message ⇒ Object
This method determines which error message to display when magic link auth is disabled for this model instance.
63 64 65 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 63 def :magic_link_invalid end |
#password ⇒ Object
Not having a #password method breaks the :validatable module
NOTE I proposed a change to Devise to fix this: github.com/heartcombo/devise/issues/5346#issuecomment-822022834 As of yet it hasn’t been accepted due to unknowns of the legacy code’s purpose
27 28 29 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 27 def password nil end |
#password_required? ⇒ Boolean
16 17 18 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 16 def password_required? false end |
#send_magic_link(remember_me: false, **kwargs) ⇒ Object
36 37 38 39 |
# File 'lib/devise/models/magic_link_authenticatable.rb', line 36 def send_magic_link(remember_me: false, **kwargs) token = self.encode_passwordless_token send_devise_notification(:magic_link, token, remember_me, **kwargs) end |