Change Password
Author: Carmine Antonio Bonavoglia Creation Date: 10/11/2025
Last Reviewer: Carmine Antonio Bonavoglia Last Updated: 10/11/2025
ChangePassword Component
Purpose
Allow users to change their Firebase password with re-authentication workflow.
Features
const handleChangePassword = async () => {
// 1. Validate new passwords match
if (newPassword !== repeatPassword) {
throw new Error("Passwords do not match");
}
// 2. Re-authenticate current user
const user = auth.currentUser;
const credential = EmailAuthProvider.credential(
user.email,
currentPassword
);
await reauthenticateWithCredential(user, credential);
// 3. Update password
await updatePassword(user, newPassword);
// 4. Clear form and show success
message.success("Password changed successfully");
};
Form Fields
- Current Password (required)
- New Password (required)
- Repeat New Password (required for validation)
Validation
- All fields must be filled to enable "Save Password" button
- Passwords must match (checked on submit)
- Firebase handles minimum password requirements
Workflow Steps
Step 1: User Input
- Input current password (verification)
- Input new password
- Repeat new password for confirmation
Step 2: Client Validation
- Check that new password matches repeat password
- Verify all fields are filled
- Check minimum password length
Step 3: Server Authentication
- Re-authenticate user with current password
- Validate credentials against Firebase Auth
Step 4: Password Update
- Update password in Firebase Authentication
- Clear form on success
- Show success message to user
Step 5: Error Handling
- Wrong current password → "Invalid current password"
- Passwords don't match → "Passwords do not match"
- Firebase error → Display specific error message