change method
Used to change the registered information.
Change information by passing a class inheriting from ChangeAuthProvider with provider
.
登録されている情報を変更する場合に利用します。
ChangeAuthProviderを継承したクラスをprovider
で渡すことにより、情報の変更を行ないます。
Implementation
Future<void> change({
required ChangeAuthProvider provider,
}) async {
await _initialize();
final account = active;
if (account == null) {
throw Exception(
"You are not signed in. Please sign in with [signIn] first.",
);
}
final userId = account.get(userIdKey, "");
if (provider is ChangeEmailAuthProvider) {
_data._setAccount(userId, {
...account,
userEmailKey: provider.email,
});
} else if (provider is ChangePasswordAuthProvider) {
_data._setAccount(userId, {
...account,
userPasswordKey: provider.password,
});
} else if (provider is ChangePhoneNumberAuthProvider) {
final code = debugSmsCode ?? generateCode(6, charSet: "01223456789");
await onSendSMS?.call(
provider.phoneNumber,
code,
provider.locale ?? defaultLocale,
);
_data._setAccount(userId, {
...account,
tmpUserPhoneNumberKey: provider.phoneNumber,
smsCodeKey: code,
});
}
await onSaved?.call(this);
}