0Pricing
AI Powered SaaS: Stripe + Auth + Billing + Deploy · Lektion

Passwort-Zurücksetzung und E-Mail-Verifizierung

Erstellen Sie sichere Abläufe zur Kontowiederherstellung und E-Mail-Verifizierung mit einmaligen Tokens, Ablaufzeiten und Transaktions-E-Mails, damit Nutzer sicher wieder Zugriff erhalten

Passwort-Zurücksetzung und E-Mail-Verifizierung ist eine kostenlose AI Powered SaaS: Stripe + Auth + Billing + Deploy-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des AI Powered SaaS: Stripe + Auth + Billing + Deploy-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der AI Powered SaaS: Stripe + Auth + Billing + Deploy-Kurs umfasst insgesamt 4 Lektionen.

Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.

Why Reset & Verify?

Users forget passwords and mistype emails. A safe password reset flow lets them recover without support, and email verification confirms the address really belongs to them, cutting spam and fake accounts.

The Token Strategy

Both flows rely on a one-time token: a random, unguessable string emailed to the user. Possessing it proves control of the inbox.

import crypto from 'crypto';
const token = crypto.randomBytes(32).toString('hex');

Storing the Token Hashed

Never store the raw token. Hash it before saving so a database leak cannot be used to reset accounts. Compare hashes when the user returns.

const hash = crypto.createHash('sha256').update(token).digest('hex');
await prisma.resetToken.create({
  data: { userId, hash, expiresAt }
});

Adding Expiry

Tokens must expire — usually 15 to 60 minutes. Store an expiresAt timestamp and reject tokens past it.

const expiresAt = new Date(Date.now() + 30 * 60 * 1000);

Requesting a Reset

The user submits their email. Generate a token, save its hash, and email a link containing the raw token. Always respond the same way to avoid leaking which emails exist.

const link = process.env.APP_URL + '/reset?token=' + token;
await sendEmail(email, 'Reset your password', link);

Sending Transactional Email

Use a provider like Resend or SendGrid for reliable delivery. Keep the message short with a clear single action.

import { Resend } from 'resend';
const resend = new Resend(process.env.RESEND_API_KEY);
await resend.emails.send({ to, subject, html });

Verifying the Token

When the user opens the link, hash the incoming token, look it up, and check it is unused and unexpired.

const hash = crypto.createHash('sha256').update(token).digest('hex');
const record = await prisma.resetToken.findFirst({
  where: { hash, expiresAt: { gt: new Date() }, usedAt: null }
});

Updating the Password

If valid, hash the new password and save it, then mark the token used so it cannot be replayed.

const pw = await bcrypt.hash(newPassword, 12);
await prisma.user.update({ where: { id: record.userId }, data: { password: pw } });
await prisma.resetToken.update({ where: { id: record.id }, data: { usedAt: new Date() } });

Email Verification Flow

Verification works the same way: on signup, email a token. When clicked, set emailVerified on the user and invalidate the token.

await prisma.user.update({
  where: { id }, data: { emailVerified: new Date() }
});

Preventing Abuse

Protect these endpoints:

  • Rate limit reset requests
  • Give identical responses for known and unknown emails
  • Allow only one active token per user

Best Practices

Build recovery securely:

  • Use random, hashed tokens with expiry
  • Send via a transactional email provider
  • Mark tokens used after one use
  • Rate limit and avoid email enumeration

Quick Check

Test your reset-flow knowledge.

Recap

You built account recovery:

  • Generate random tokens, store them hashed with expiry
  • Email links via a transactional provider
  • Verify, then update the password and mark the token used
  • Reuse the pattern for email verification and guard against abuse

Users can now safely recover and verify accounts.

Häufig gestellte Fragen

Ist die Lektion „Passwort-Zurücksetzung und E-Mail-Verifizierung“ kostenlos?

Ja — der vollständige Text von „Passwort-Zurücksetzung und E-Mail-Verifizierung“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des AI Powered SaaS: Stripe + Auth + Billing + Deploy-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der AI Powered SaaS: Stripe + Auth + Billing + Deploy-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Passwort-Zurücksetzung und E-Mail-Verifizierung“?

Erstellen Sie sichere Abläufe zur Kontowiederherstellung und E-Mail-Verifizierung mit einmaligen Tokens, Ablaufzeiten und Transaktions-E-Mails, damit Nutzer sicher wieder Zugriff erhalten Du übst AI Powered SaaS: Stripe + Auth + Billing + Deploy mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.

Brauche ich Erfahrung, um AI Powered SaaS: Stripe + Auth + Billing + Deploy zu starten?

Keine Vorkenntnisse erforderlich. AI Powered SaaS: Stripe + Auth + Billing + Deploy auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.

Wie lange dauert die Lektion „Passwort-Zurücksetzung und E-Mail-Verifizierung“?

Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.

Kann ich in dieser AI Powered SaaS: Stripe + Auth + Billing + Deploy-Lektion Code schreiben und ausführen?

Ja. Jede AI Powered SaaS: Stripe + Auth + Billing + Deploy-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.

Alle Lektionen in diesem Kurs

  1. Benutzerregistrierung und Hashing
  2. Login und JWT-Generierung
  3. Geschützte Routen und Middleware
  4. Passwort-Zurücksetzung und E-Mail-Verifizierung
← Zurück zu AI Powered SaaS: Stripe + Auth + Billing + Deploy