Prompt

How do I build a reliable password reset flow with email?

Technology / API Platforms1 observationLast seen Oct 23, 2026

Latest observation

Oct 23, 2026OpenAI APIWeb search: off

A reliable password reset flow should prioritize security, deliverability, and simplicity. Here’s a solid pattern that works well in practice.

Recommended flow

1) User requests a reset

  • User enters their email address on a “Forgot password?” page.
  • Always respond with a generic message like:
    • “If an account exists for that email, we’ve sent reset instructions.”
  • Don’t reveal whether the email exists.

2) Generate a reset token

  • Create a cryptographically secure random token.
  • Make it:
    • single-use
    • short-lived (commonly 15–60 minutes)
    • stored hashed in your database, not in plaintext
  • Associate it with:
    • user ID
    • expiration timestamp
    • created timestamp
    • optional metadata like IP / user agent for audit

3) Email the reset link

Send an email with a link such as:

https://yourapp.com/reset-password?token=...

Best practices:

  • Use a clear subject: “Reset your password”
  • Keep the email simple and concise
  • Include:
    • a primary button/link
    • fallback plain-text URL
    • expiration notice
    • “If you didn’t request this, ignore this email”
  • Consider not including the user’s email address if that leaks sensitive info in forwarded mailboxes.

4) Validate the token on the server

When the user opens the link:

  • Verify the token exists
  • Hash the incoming token and compare to stored hash
  • Check expiry
  • Check it hasn’t already been used
  • If valid, show a password reset form

5) Set the new password

When the form is submitted:

  • Enforce password policy
  • Hash the new password with a strong algorithm like:
    • Argon2id preferred
    • or bcrypt/scrypt if needed
  • Mark the reset token as used immediately
  • Invalidate any other active reset tokens for that user

6) Log the user in or require re-login

After reset:

  • Either log the user in automatically, or
  • Require them to sign in again

For higher security, it’s often better to:

  • invalidate all existing sessions
  • notify the user by email that the password was changed

Security checklist

Token security

  • Use at least 32 bytes of random data
  • Encode with URL-safe Base64 or hex
  • Store only a hash of the token
  • One token per request, one use only

Timing and leakage

  • Always return the same response for:
    • existing email
    • non-existing email
  • Avoid detailed error messages like “token invalid vs expired” unless needed
  • Rate-limit reset requests by:
    • IP
    • email address
    • device fingerprint if appropriate

Abuse prevention

  • Add rate limiting and possibly CAPTCHA after repeated requests
  • Monitor for spikes
  • Consider cooldowns per account, e.g. no more than 1 email every few minutes

Session management

  • After password reset:
    • revoke all refresh tokens
    • invalidate session cookies / server sessions
    • rotate “remember me” tokens
  • Notify the user if possible

Email deliverability

  • Use a reputable email provider
  • Set up:
    • SPF
    • DKIM
    • DMARC
  • Make sure reset emails are sent from a trusted domain
  • Avoid spammy wording and excessive formatting

Good implementation pattern

Database table for reset tokens

Example fields:

  • user_id
  • token_hash
  • expires_at
  • used_at
  • created_at
  • request_ip
  • user_agent

Token handling

Pseudo-flow:

  1. Generate raw token
  2. Store hash(token) in DB
  3. Email raw token
  4. On submit, hash received token and look it up
  5. If valid, allow password reset
  6. Mark token used and invalidate sessions

Common mistakes to avoid

  • Storing tokens in plaintext
  • Tokens that never expire
  • Allowing token reuse
  • Revealing whether an email exists
  • Sending reset links over insecure HTTP
  • Failing to invalidate old sessions
  • Using weak password hashing
  • Not rate-limiting requests
  • Putting sensitive info in query params without HTTPS

Extra hardening options

If your app is high-risk, consider:

  • Re-authentication for critical changes
  • MFA required before password reset completion
  • Email notification after request and after completion
  • Device/session history so users can spot suspicious activity

Minimal “best practice” version

If you want the shortest robust recipe:

  • Ask for email
  • Always show the same success message
  • Generate secure random token
  • Store hashed token with 30-minute expiry
  • Email a reset link over HTTPS
  • Validate token server-side
  • Let user set new password
  • Hash password with Argon2id
  • Mark token used
  • Revoke all sessions
  • Notify user of the change
  • Rate-limit requests

If you want, I can also provide:

  1. a database schema,
  2. backend pseudocode, or
  3. a complete implementation example in Node.js, Python, or Go.

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.