Prompt

How do I let users sign in with email magic links instead of passwords?

Technology / Identity & Access1 observationLast seen Oct 28, 2026

Latest observation

Oct 28, 2026OpenAI APIWeb search: off

To let users sign in with email magic links instead of passwords, you typically implement a passwordless authentication flow:

Basic flow

  1. User enters their email address.
  2. Your backend generates a single-use, time-limited token.
  3. You email the user a link like: https://yourapp.com/auth/verify?token=...
  4. When they click it, your backend:
    • verifies the token
    • checks it hasn’t expired or been used
    • logs the user in
  5. Create a session cookie or issue a JWT after verification.

Important security rules

  • Token must expire quickly: usually 10–30 minutes.
  • Single use only: invalidate after first successful login.
  • Store token hashed in the database, not in plaintext.
  • Rate limit requests to prevent abuse/spam.
  • Don’t reveal whether an email exists in your system.
  • Bind the token to the email address and optionally to device/session context.
  • Use HTTPS only.

Typical implementation outline

1. Request magic link

Frontend sends:

POST /auth/magic-link
{ "email": "user@example.com" }

Backend:

  • normalizes email
  • generates random token
  • stores hashed token + expiry + email
  • sends email with link

2. Verify magic link

User clicks:

GET /auth/verify?token=abc123

Backend:

  • hashes received token
  • looks it up in database
  • verifies expiry and unused status
  • marks token as used
  • creates authenticated session

Data model example

A simple table might include:

  • id
  • email
  • token_hash
  • expires_at
  • used_at
  • created_at
  • ip_address / user_agent optional

Email example

Subject: Your sign-in link

Body:

Click this link to sign in: https://yourapp.com/auth/verify?token=...

This link expires in 15 minutes.

UX recommendations

  • Show: “We sent you a sign-in link.”
  • If possible, detect when the email client opens the link in a different browser and provide fallback help.
  • Allow resending after a short delay.
  • Consider showing a list of recent login attempts in account security settings.

If you don’t want to build it yourself

Many auth providers support this out of the box:

  • Auth0
  • Firebase Auth
  • Clerk
  • Supabase Auth
  • Magic.link
  • NextAuth / Auth.js (with email provider)

Example pseudocode

// request link
token = randomSecureToken()
hash = sha256(token)
saveToDb({ email, hash, expiresAt: now + 15min, usedAt: null })
sendEmail(email, `https://yourapp.com/auth/verify?token=${token}`)

// verify link
record = findByHash(sha256(token))
if (!record || record.usedAt || record.expiresAt < now) reject()
markUsed(record)
createSession(record.email)

If you want, I can also give you:

  • a Node.js/Express example
  • a Next.js/Auth.js setup
  • a Django/Rails implementation
  • or a production-ready database schema and email template

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.