create method
Register a user by passing a class inheriting from CreateAuthProvider in provider
.
CreateAuthProviderを継承したクラスをprovider
で渡すことにより、ユーザーの登録を行います。
Implementation
Future<String?> create({
required CreateAuthProvider provider,
}) async {
String? userId;
await _initialize();
if (provider is EmailAndPasswordCreateAuthProvider) {
if (_data.containsKey(userEmailKey)) {
throw Exception(
"This Email address is already registered. Please register another email address.",
);
}
final accounts = _data._getAccounts();
if (accounts
.any((element) => element.get(userEmailKey, "") == provider.email)) {
throw Exception(
"This Email address is already registered. Please register another email address.",
);
}
userId = _uuid;
_data._setAccount(
userId,
{
userIdKey: userId,
userEmailKey: provider.email,
userPasswordKey: provider.password,
activeProvidersKey: [
...activeProviderIds,
provider.providerId,
].distinct(),
},
);
await onSendRegisteredEmail?.call(
provider.email,
provider.password,
provider.locale ?? defaultLocale,
);
}
await onSaved?.call(this);
return userId;
}