Module: Studio::LinkConsumption
- Extended by:
- ActiveSupport::Concern
- Included in:
- LinksController
- Defined in:
- app/controllers/concerns/studio/link_consumption.rb
Overview
The magic-link click, start to finish — shared by Studio::LinksController and by any app that draws its own token route (turf-monster's contest landing). Two entry points bracket the single-use burn:
preview_magic_link(link) — the GET. NEVER burns. Returns :live for a link
that is still good (the caller renders the scanner-safe interstitial),
and otherwise settles the click here and returns :handled.
consume_magic_link(link) — the POST. The one and only place a token burns.
Both route their answer through Studio::LinkResolution, the pure decision table, so "what should this click do" has exactly one owner and the GET and the POST can never disagree about it. The invariant that table enforces: a dead link never touches the session.
Apps customize by overriding the hooks at the bottom, not by re-deciding:
sign_in_existing / sign_up_new (the authenticate path), link_continue (the
viewer's own live link), link_dead (no session mutation, ever), plus
link_login_path / link_home_path for apps whose sign-in page is not
login_path.
link is anything responding to #email, #return_to, #live?, #burn and
#dead_status — in practice a Studio::Link, or nil for an unknown token.
Relies on the host ApplicationController contract from Studio::ErrorHandling: set_app_session, rescue_and_log, current_user, plus root_path / login_path.