]> Repos - crimata-website/commit
Add passwordless email auth with pre-checkout signup
authorAndrew Gundersen <adgundersen@gmail.com>
Fri, 27 Feb 2026 22:12:23 +0000 (17:12 -0500)
committerAndrew Gundersen <adgundersen@gmail.com>
Fri, 27 Feb 2026 22:12:23 +0000 (17:12 -0500)
commita1175ab00d3218206e49ebe41e1073d22797494e
tree1ed8bd49e191baa76f0d6b3355c63d90b563dd6a
parentfd2d4981414feb84b06ac00e518c1e4da9dd1a20
Add passwordless email auth with pre-checkout signup

Flow: enter email → magic link → verified → Stripe checkout → dashboard

- SessionsController: new/create (send magic link), sent, verify, destroy
- Customer model: generate_magic_token!, magic_token_valid?, verify_email!
- Migration: magic_token, magic_token_expires_at, email_verified_at + unique indexes
- CustomerMailer + mailer layout with magic link email (html + text)
- CheckoutController: GET /checkout/start requires auth, passes customer_id
  as Stripe metadata; webhook finds customer by metadata and updates record
- DashboardController: requires auth, uses current_customer from session
- ApplicationController: current_customer, require_auth, redirect_after_auth
  (stores return_to so verify sends user back to where they were headed)
- Resend gem + initializer; production uses :resend delivery method
- Dev logs magic link URL to Rails logger instead of sending email
- Pricing page: simple link to /checkout/start (no more JS fetch)
- Layout: Sign in / Dashboard / Sign out nav links

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
22 files changed:
Gemfile
app/controllers/application_controller.rb
app/controllers/checkout_controller.rb
app/controllers/dashboard_controller.rb
app/controllers/sessions_controller.rb [new file with mode: 0644]
app/mailers/application_mailer.rb [new file with mode: 0644]
app/mailers/customer_mailer.rb [new file with mode: 0644]
app/models/customer.rb
app/views/customer_mailer/magic_link.html.erb [new file with mode: 0644]
app/views/customer_mailer/magic_link.text.erb [new file with mode: 0644]
app/views/layouts/application.html.erb
app/views/layouts/mailer.html.erb [new file with mode: 0644]
app/views/layouts/mailer.text.erb [new file with mode: 0644]
app/views/pages/pricing.html.erb
app/views/sessions/new.html.erb [new file with mode: 0644]
app/views/sessions/sent.html.erb [new file with mode: 0644]
config/application.rb
config/environments/development.rb
config/environments/production.rb
config/initializers/resend.rb [new file with mode: 0644]
config/routes.rb
db/migrate/20260227100000_add_auth_fields_to_customers.rb [new file with mode: 0644]