updateProfile method
Implementation
@override
Future<UserModel> updateProfile({String? displayName, String? photoURL}) async {
try {
final user = _firebaseAuth.currentUser;
if (user == null) {
throw const AuthException('No user logged in');
}
await user.updateDisplayName(displayName);
if (photoURL != null) {
await user.updatePhotoURL(photoURL);
}
await user.reload();
final updatedUser = _firebaseAuth.currentUser;
if (updatedUser == null) {
throw const AuthException('Failed to update profile');
}
return UserModel.fromFirebaseUser(updatedUser);
} on firebase_auth.FirebaseAuthException catch (e) {
throw AuthException(_getErrorMessage(e.code));
} catch (e) {
throw AuthException('Failed to update profile: ${e.toString()}');
}
}