reset method
Used to reset the password.
Reset is performed by passing a class inheriting from ResetAuthProvider in provider
.
パスワードをリセットする場合に利用します。
ResetAuthProviderを継承したクラスをprovider
で渡すことにより、リセットを行ないます。
Implementation
Future<void> reset({
required ResetAuthProvider provider,
}) async {
await _initialize();
if (provider is EmailAndPasswordResetAuthProvider) {
final account = _data._getAccounts().firstWhereOrNull(
(item) => item.get(userEmailKey, "") == provider.email,
);
if (account == null) {
throw Exception("Account not found.");
}
final password = await onResetPassword?.call(
resetPassword,
provider.locale ?? defaultLocale,
);
account[userPasswordKey] = password;
_data._setAccount(userId, account);
} else {
throw Exception(
"This provider is not supported: ${provider.runtimeType}",
);
}
await onSaved?.call(this);
}