updatePassword method
Update the current user's password
Requires recent authentication - call reauthenticateWithPassword first.
Implementation
@override
Future<Either<AuthServiceSignInFailure, Unit>> updatePassword(
String newPassword,
) async {
try {
final user = _fbAuth.currentUser;
if (user == null) {
logw('updatePassword: No user logged in');
return left(AuthServiceSignInFailure.userNotFound);
}
logd('updatePassword: Updating password');
await user.updatePassword(newPassword);
logd('updatePassword: Password updated successfully');
return right(unit);
} on fb_auth.FirebaseAuthException catch (e) {
loge(e, 'updatePassword failed');
switch (e.code) {
case 'weak-password':
return left(AuthServiceSignInFailure.weakPassword);
case 'requires-recent-login':
return left(AuthServiceSignInFailure.invalidCredential);
default:
return left(AuthServiceSignInFailure.unexpected);
}
} catch (e) {
loge(e, 'updatePassword failed');
return left(AuthServiceSignInFailure.unexpected);
}
}