Class: Passwordless::Mailer

Inherits:
Object
  • Object
show all
Defined in:
app/mailers/passwordless/mailer.rb

Overview

The mailer responsible for sending Passwordless’ mails.

Instance Method Summary collapse

Instance Method Details

#sign_in(session, token = nil, url_options = {}) ⇒ Object

Sends a token and a magic link

is still in memory (optional)

Parameters:

  • session (Session)

    An instance of Passwordless::Session

  • token (String) (defaults to: nil)

    The token in plaintext. Falls back to ‘session.token` hoping it



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/mailers/passwordless/mailer.rb', line 13

def (session, token = nil, url_options = {})
  @token = token || session.token

  @magic_link = Passwordless.context.url_for(
    session,
    action: "confirm",
    id: session.to_param,
    token: @token,
    **url_options,
    **default_url_options
  )

  email_field = session.authenticatable.class.passwordless_email_field

  mail(
    to: session.authenticatable.send(email_field),
    subject: I18n.t("passwordless.mailer.sign_in.subject")
  )
end