Restablecimiento de contraseñas y verificación de correo electrónico
Complete la autenticación con correo electrónico y contraseña permitiendo que los usuarios restablezcan contraseñas olvidadas y verifiquen sus direcciones de correo, mejorando tanto la seguridad como la recuperación de cuentas.
Restablecimiento de contraseñas y verificación de correo electrónico es una lección gratuita de Firebase Auth & Realtime Database Apps en CoddyKit. Esta es la lección 4 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Firebase Auth & Realtime Database Apps, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Firebase Auth & Realtime Database Apps incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Why Reset and Verification Matter
Email/password sign-in is incomplete without two flows: password reset for forgotten credentials and email verification to prove the user owns the address.
- Reset reduces support tickets and lockouts
- Verification blocks fake or mistyped emails
How Password Reset Works
The flow is entirely email-driven so the user never reveals an old password:
- User requests a reset for their email
- Firebase sends a secure, time-limited link
- User clicks it and chooses a new password
Your app only triggers the email; Firebase hosts the reset page by default.
Triggering a Reset Email
Call sendPasswordResetEmail with the user's address. Firebase handles delivery and the link.
import { getAuth, sendPasswordResetEmail } from 'firebase/auth';
const auth = getAuth();
await sendPasswordResetEmail(auth, 'user@example.com');
console.log('Reset email sent');Handling Reset Errors Gracefully
For security, avoid revealing whether an email exists. Show the same confirmation message whether or not the account is found.
try {
await sendPasswordResetEmail(auth, email);
} catch (e) {
// log internally but do not expose to user
}
showMessage('If that email exists, a reset link was sent.');Sending a Verification Email
After a user signs up, send a verification email with sendEmailVerification on the current user object.
import { getAuth, sendEmailVerification } from 'firebase/auth';
const user = getAuth().currentUser;
if (user) {
await sendEmailVerification(user);
}Checking Verification Status
The user object exposes emailVerified. Use it to gate sensitive features until the address is confirmed.
const user = getAuth().currentUser;
if (user && !user.emailVerified) {
showBanner('Please verify your email to continue.');
}Refreshing the Token After Verification
The emailVerified flag is cached in the ID token. After a user verifies, call reload to refresh their local state.
const user = getAuth().currentUser;
await user.reload();
console.log('Verified now?', user.emailVerified);Customizing Email Templates
In the Firebase console under Authentication > Templates you can customize the sender name, subject, and body of reset and verification emails, and set a custom action URL for branded pages.
Enforcing Verification
You can require a verified email before granting access to certain data using Security Rules. Tokens carry an email_verified claim you can check.
{
"rules": {
"posts": {
".write": "auth != null && auth.token.email_verified == true"
}
}
}Rate Limiting and Abuse
Firebase throttles repeated reset and verification requests to prevent abuse and spam. In your UI, disable the button briefly after sending so users do not trigger the limit accidentally.
Putting It Together
A complete signup typically looks like: create account, send verification email, show a 'check your inbox' screen, and reveal full features once emailVerified becomes true. A 'Forgot password?' link calls the reset flow.
Quick Check
Test your understanding of reset and verification.
Recap
Your email/password auth is now complete and recoverable.
- Use
sendPasswordResetEmailfor forgotten passwords - Avoid revealing whether an email exists
- Verify ownership with
sendEmailVerificationandemailVerified - Call
reloadto refresh status - Customize templates and enforce verification via rules
Aprende Firebase Auth & Realtime Database Apps con un tutor de IA — gratis
Escribe y ejecuta código real en tu navegador, obtén ayuda instantánea de un tutor de IA disponible 24/7 y continúa donde lo dejaste en la web o en la aplicación.
- Cursos
- 11
- Lecciones
- 44
Preguntas frecuentes
¿La lección «Restablecimiento de contraseñas y verificación de correo electrónico» es gratis?
Sí — el texto completo de «Restablecimiento de contraseñas y verificación de correo electrónico» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Firebase Auth & Realtime Database Apps, actualiza a CoddyKit PRO. El curso de Firebase Auth & Realtime Database Apps incluye 4 lecciones en total.
¿Qué aprenderé en «Restablecimiento de contraseñas y verificación de correo electrónico»?
Complete la autenticación con correo electrónico y contraseña permitiendo que los usuarios restablezcan contraseñas olvidadas y verifiquen sus direcciones de correo, mejorando tanto la seguridad como… Practicas Firebase Auth & Realtime Database Apps con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Firebase Auth & Realtime Database Apps?
No se requiere experiencia previa. Firebase Auth & Realtime Database Apps en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 4 de 4.
¿Cuánto tiempo toma la lección «Restablecimiento de contraseñas y verificación de correo electrónico»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Firebase Auth & Realtime Database Apps?
Sí. Cada lección de Firebase Auth & Realtime Database Apps incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Implementación de autenticación con correo electrónico y contraseña
- Gestión de sesiones y estados de usuario
- Gestión de errores de autenticación
- Restablecimiento de contraseñas y verificación de correo electrónico