-
-
Notifications
You must be signed in to change notification settings - Fork 86
/
mailer.rb
22 lines (18 loc) · 714 Bytes
/
mailer.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true
module Passwordless
# The mailer responsible for sending Passwordless' mails.
class Mailer < Passwordless.parent_mailer.constantize
default from: Passwordless.default_from_address
# Sends a magic link (secret token) email.
# @param session [Session] A Passwordless Session
def magic_link(session)
@session = session
@magic_link = send(:"#{session.authenticatable_type.downcase.pluralize}_token_sign_in_url", session.token)
email_field = @session.authenticatable.class.passwordless_email_field
mail(
to: @session.authenticatable.send(email_field),
subject: I18n.t("passwordless.mailer.subject")
)
end
end
end