You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
38 lines
1.1 KiB
require "cgi"
|
|
|
|
# Devise calls these methods with (record, token, options). Using a regular
|
|
# ActionMailer class keeps the API independent from Devise's controller/route
|
|
# mapping, which is not present in an API-only application.
|
|
class UserMailer < ApplicationMailer
|
|
def confirmation_instructions(record, token, opts = {})
|
|
@resource = record
|
|
@token = token
|
|
@confirmation_url = "#{frontend_url}/confirm-email?token=#{CGI.escape(token)}"
|
|
|
|
mail(
|
|
to: record.email,
|
|
subject: opts[:subject].presence || "E-Mail-Adresse bestätigen",
|
|
template_path: "devise/mailer",
|
|
template_name: "confirmation_instructions"
|
|
)
|
|
end
|
|
|
|
def reset_password_instructions(record, token, opts = {})
|
|
@resource = record
|
|
@token = token
|
|
@reset_password_url = "#{frontend_url}/reset-password?token=#{CGI.escape(token)}"
|
|
|
|
mail(
|
|
to: record.email,
|
|
subject: opts[:subject].presence || "Passwort zurücksetzen",
|
|
template_path: "devise/mailer",
|
|
template_name: "reset_password_instructions"
|
|
)
|
|
end
|
|
|
|
private
|
|
|
|
def frontend_url
|
|
ENV.fetch("FRONTEND_URL", "http://localhost:13131").delete_suffix("/")
|
|
end
|
|
end
|