Module: Passwordless::ModelHelpers

Defined in:
lib/passwordless/model_helpers.rb

Overview

Some helpers for models that can sign in passswordlessly.

Instance Method Summary collapse

Instance Method Details

#passwordless_with(field) ⇒ Object

Creates relationship - has_many :passwordless_sessions Defines a method ‘Class.passwordless_email_field` returning its email

field name (e.g. `:email`)

Parameters:

  • field (string)

    email submitted by user.



10
11
12
13
14
15
16
17
18
# File 'lib/passwordless/model_helpers.rb', line 10

def passwordless_with(field)
  has_many(
    :passwordless_sessions,
    class_name: "Passwordless::Session",
    as: :authenticatable
  )

  define_singleton_method(:passwordless_email_field) { field }
end