Class: UserMailer

Inherits:
ApplicationMailer show all
Includes:
Studio::MagicLinkIssuing
Defined in:
app/mailers/user_mailer.rb

Instance Method Summary collapse

Instance Method Details

Passwordless sign-in link. email is a raw string (the recipient may not have an account yet). The token is a Studio::Link row's short token — 16 URL-safe characters, single-use, expiring — and the email + return_to it stands for stay in the row, off the wire. Clicking the link logs the recipient in or creates their account. App-name-aware so the same template serves every Studio app.

Engine GENERIC base. An app needing richer copy (e.g. turf-monster's contest-aware variant) defines its own UserMailer, which wins.



20
21
22
23
24
25
26
27
28
29
30
# File 'app/mailers/user_mailer.rb', line 20

def magic_link(email, token)
  @app_name   = Studio.app_name
  @email      = email
  @magic_url  = magic_link_url_for(token)
  # resolved_url, not url: this app's own upload if it has one, otherwise the
  # engine's default banner — which is what makes a brand-new app's sign-in
  # email branded on day one. nil renders bannerless.
  @banner_url = Studio::EmailCatalog.resolved_url(:magic_link)
  @banner_alt = "Your #{@app_name} sign-in link"
  mail(to: email, subject: "Your #{@app_name} sign-in link")
end