updateUserPassword method
- UserPassword? oldPassword,
- UserPassword newPassword
override
Updates password for the authenticated MyUser.
If MyUser has no password yet (when sets his password), then old
password is not required. Otherwise (when changes his password), it's
mandatory to specify the old one.
Implementation
@override
Future<void> updateUserPassword(
UserPassword? oldPassword,
UserPassword newPassword,
) async {
Log.debug(
'updateUserPassword(${oldPassword?.obscured}, ${newPassword.obscured})',
'$runtimeType',
);
final bool? hasPassword = myUser.value?.hasPassword;
myUser.update((u) => u?.hasPassword = true);
try {
await _graphQlProvider.updateUserPassword(
confirmation: oldPassword == null
? null
: MyUserCredentials(password: oldPassword),
newPassword: newPassword,
);
} catch (_) {
if (hasPassword != null) {
myUser.update((u) => u?.hasPassword = hasPassword);
}
rethrow;
}
}