abevoelker/devise-passwordless

Pass a different host or _url options to mailer `magic_link_url`

Closed this issue · 0 comments

I have a multi-tenant site and need to keep the host / subdomain from the request and pass it into the magic_link_url in the mailer somehow.

I made a monkey patch but maybe there is a better way to handle this - #49

With this you can do:

resource&.send_magic_link(remember_me: create_params[:remember_me], opts: {host: request.host})

and in the mailer you can:

magic_link_url(@resource, @scope_name => {email: @resource.email, token: @token, remember_me: @remember_me},
  host: @opts.dig(:opts)&.dig(:host) || Rails.application.config.action_mailer.default_url_options[:host]
)