Supabase Backend as a Service · Lektion

Passwortzurücksetzung und Authentifizierung per Magic Link

Fügen Sie Ihrer Supabase-Authentifizierung passwortlose Magic Links und einen sicheren Ablauf zur Passwortzurücksetzung hinzu, einschließlich der Schritte für Weiterleitung und Token-Austausch.

Lektion 4 von 413 Schritte

Passwortzurücksetzung und Authentifizierung per Magic Link ist eine kostenlose Supabase Backend as a Service-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 Supabase Backend as a Service-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der Supabase Backend as a Service-Kurs umfasst insgesamt 4 Lektionen.

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

Beyond Passwords

Supabase supports passwordless sign-in via magic links and a built-in password reset flow. Both rely on emailing a secure link to the user.

How Magic Links Work

The user enters an email, Supabase emails a one-time link, and clicking it signs them in, no password needed.

  • Link contains a single-use token
  • Token is exchanged for a session

Sending a Magic Link

Call signInWithOtp with the email and a redirect URL.

const { error } = await supabase.auth.signInWithOtp({
  email: 'user@example.com',
  options: { emailRedirectTo: 'https://app.example.com/welcome' }
});

Configuring Redirect URLs

In the dashboard under Authentication > URL Configuration, allow-list your redirect URLs. Links to non-listed URLs are rejected for security.

Completing the Sign-In

When the user returns, Supabase detects the token in the URL and establishes the session automatically with detectSessionInUrl enabled.

const { data } = await supabase.auth.getSession();
console.log(data.session ? 'Signed in' : 'No session');

Starting a Password Reset

Trigger a reset email with resetPasswordForEmail. The link sends the user to a page where they set a new password.

await supabase.auth.resetPasswordForEmail(
  'user@example.com',
  { redirectTo: 'https://app.example.com/update-password' }
);

Setting the New Password

On the redirect page, the user is in a temporary recovery session. Update the password with updateUser.

const { error } = await supabase.auth.updateUser({
  password: 'a-strong-new-password'
});

Validating Password Strength

Enforce a minimum standard before submitting to reduce weak credentials.

function strong(pw) {
  return pw.length >= 8 && /[0-9]/.test(pw) && /[A-Za-z]/.test(pw);
}
console.log(strong('abc12345'));

Token Expiry

Magic links and reset tokens are short-lived and single use. Expired links must trigger a fresh request, so always handle the expiry error gracefully.

Customizing Email Templates

Under Authentication > Email Templates you can brand the magic link and recovery emails so they match your product.

Putting It Together

Magic links remove password friction, and the reset flow gives users a safe recovery path. Both depend on allow-listed redirects and short-lived tokens.

Quick Check

Test your understanding of magic links and resets.

Recap

You added magic link sign-in with signInWithOtp, built a password reset flow with resetPasswordForEmail and updateUser, and learned why allow-listed redirects and short-lived tokens keep it secure.

Kostenlos starten

Lerne Supabase Backend as a Service mit einem KI-Tutor — kostenlos

Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.

Kurse
11
Lektionen
40

Häufig gestellte Fragen

Ist die Lektion „Passwortzurücksetzung und Authentifizierung per Magic Link“ kostenlos?

Ja — der vollständige Text von „Passwortzurücksetzung und Authentifizierung per Magic Link“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des Supabase Backend as a Service-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der Supabase Backend as a Service-Kurs umfasst insgesamt 4 Lektionen.

Was lerne ich in „Passwortzurücksetzung und Authentifizierung per Magic Link“?

Fügen Sie Ihrer Supabase-Authentifizierung passwortlose Magic Links und einen sicheren Ablauf zur Passwortzurücksetzung hinzu, einschließlich der Schritte für Weiterleitung und Token-Austausch. Du übst Supabase Backend as a Service 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 Supabase Backend as a Service zu starten?

Keine Vorkenntnisse erforderlich. Supabase Backend as a Service 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 „Passwortzurücksetzung und Authentifizierung per Magic Link“?

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 Supabase Backend as a Service-Lektion Code schreiben und ausführen?

Ja. Jede Supabase Backend as a Service-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 mit E-Mail und Passwort
  2. Social Logins (OAuth-Provider)
  3. Benutzersitzungen und Profile verwalten
  4. Passwortzurücksetzung und Authentifizierung per Magic Link
← Zurück zu Supabase Backend as a Service