AuthDatabase class
A database for managing authentication information locally.
It is used for testing authentication, for example.
It is possible to implement settings during initialization with onInitialize.
You can describe the process of restoring authentication information with tryRestoreAuth in onLoad, and when there is a change in authentication, you can save the information with onSaved.
This also allows authentication information to be stored locally within the terminal.
It is possible to test each email and SMS sending process with onSendRegisteredEmail, onSendEmailLink, onSendSMS, onResetPassword and onVerify.
The password to be reset when reset is executed can be specified in resetPassword.
ローカルで認証情報を管理するためのデータベース。
認証をテストする際などに利用します。
onInitializeで初期化時の設定を実装することが可能です。
onLoadでtryRestoreAuthで認証情報を復元する際の処理を記述することができ、認証に変更があった場合、onSavedで情報を保存することができます。
これにより、端末ローカル内に認証情報を保存することも可能です。
onSendRegisteredEmailやonSendEmailLink、onSendSMS、onResetPassword、onVerifyで各メールやSMSの送信処理をテストすることが可能です。
resetが実行された場合リセットされるパスワードをresetPasswordで指定することが可能です。
- Available Extensions
Constructors
-
AuthDatabase({Future<
void> onInitialize(AuthDatabase database)?, Future<void> onLoad(AuthDatabase database)?, Future<void> onSaved(AuthDatabase database)?, Future<void> onSendRegisteredEmail(String email, String password, Locale locale)?, Future<void> onSendEmailLink(String email, String url, Locale locale)?, Future<String> onSendSMS(String phoneNumber, String code, Locale locale)?, Future<String> onResetPassword(String newPassword, Locale locale)?, Future<bool> onVerify(String email, Locale locale)?, String resetPassword = "01234567", String? debugSmsCode, String? debugUserId, Locale defaultLocale = const Locale("en", "US")}) - A database for managing authentication information locally.
Properties
-
accounts
→ List<
DynamicMap> -
A list of currently registered accounts.
no setter
- active → DynamicMap?
-
An active, logged-in account.
no setter
-
activeProviderIds
→ List<
String> -
Returns a list of authenticated provider IDs upon sign-in.
no setter
- current → DynamicMap?
-
An account that is not logged in but can be restored with tryRestoreAuth.
no setter
- debugSmsCode → String?
-
If this is specified, this string will be used preferentially when generating Sms code.
final
- debugUserId → String?
-
If this string is specified, it will be used preferentially when creating
_uuid
.final - defaultLocale → Locale
-
Default locale when Locale is not set.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAnonymously → bool
-
Returns
true
in case of anonymous or guest authentication.no setter - isInitialValueRegistered → bool
-
Returns
true
if data is registered with setInitialValue.no setter - isSignedIn → bool
-
If you are signed in,
true
is returned.no setter - isVerified → bool
-
Returns
true
if the registration has been authenticated.no setter - isWaitingConfirmation → bool
-
Returns
true
if confirmSignIn or confirmChange is required.no setter -
onInitialize
→ (Future<
void> Function(AuthDatabase database)?) -
Executed at Database initialization time.
final
-
onLoad
→ (Future<
void> Function(AuthDatabase database)?) -
Executed when loading Database.
final
-
onResetPassword
→ (Future<
String> Function(String newPassword, Locale locale)?) -
This is performed when resetting a password.
final
-
onSaved
→ (Future<
void> Function(AuthDatabase database)?) -
Executed when saving the Database.
final
-
onSendEmailLink
→ (Future<
void> Function(String email, String url, Locale locale)?) -
Executed when issuing a mail link.
final
-
onSendRegisteredEmail
→ (Future<
void> Function(String email, String password, Locale locale)?) -
It is executed when the registration completion email is sent.
final
-
onSendSMS
→ (Future<
String> Function(String phoneNumber, String code, Locale locale)?) -
It is executed when sending an SMS.
final
-
onVerify
→ (Future<
bool> Function(String email, Locale locale)?) -
It is executed when sending an authentication email.
final
-
registeredInitialValuePaths
→ List<
String> -
Returns a list of registered initial value paths.
no setter
- resetPassword → String
-
Password to be reset when reset is executed.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- temporary → DynamicMap?
-
Account being prepared for login.
no setter
- userEmail → String
-
Returns the email address registered with the authentication platform upon sign-in.
no setter
- userId → String
-
Returns the user ID on the authentication platform during sign-in.
no setter
- userName → String
-
Returns the user name on the authentication platform during sign-in.
no setter
- userPassword → String
-
Returns the stored password.
no setter
- userPhoneNumber → String
-
Returns the phone number registered with the authentication platform upon sign-in.
no setter
- userPhotoURL → String
-
Returns the URL of the user's icon registered on the authentication platform during sign-in.
no setter
Methods
-
change(
{required ChangeAuthProvider provider}) → Future< void> - Used to change the registered information.
-
confirmChange(
{required ConfirmChangeAuthProvider provider}) → Future< void> - If you change with ChangePhoneNumberAuthProvider, for example, you need to check the authentication code you received from an email or SMS. In that case, use this method to finalize the change.
-
confirmSignIn(
{required ConfirmSignInAuthProvider provider}) → Future< void> - If you signIn with EmailLinkSignInAuthProvider or SmsSignInAuthProvider, you need to check the authentication code received from email or SMS. In that case, use this method to finalize the sign-in.
-
create(
{required CreateAuthProvider provider}) → Future< String?> -
Register a user by passing a class inheriting from CreateAuthProvider in
provider
. -
delete(
) → Future< void> - Deletes already registered users.
-
dispose(
) → void - Destroy the database.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reauth(
{required ReAuthProvider provider}) → Future< bool> - If you are signed in, this is used to perform an authentication check just before changing information for authentication (e.g., email address).
-
register(
{required RegisterAuthProvider provider}) → Future< void> -
Register a user by passing a class inheriting from RegisterAuthProvider in
provider
. -
reset(
{required ResetAuthProvider provider}) → Future< void> - Used to reset the password.
-
setInitialId(
String? uid) → void -
setInitialValue(
AuthInitialValue value) → void -
Add/update the data of
value
at the position ofpath
. -
signIn(
{required SignInAuthProvider provider}) → Future< void> -
Sign-in is performed by passing a class inheriting from SignInAuthProvider as
provider
. -
signOut(
) → Future< void> - Sign out if you are already signed in.
-
toString(
) → String -
A string representation of this object.
inherited
-
tryRestoreAuth(
) → Future< bool> - Running the application at startup will automatically re-authenticate the user.
-
verify(
{required VerifyAuthProvider provider}) → Future< void> - Used to prove possession of the e-mail address.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- activeProvidersKey → const String
- User's active provider ID key.
- anonymouslyKey → const String
- Key to anonymous or not.
- emailLinkUrlKey → const String
- URL for email link.
- smsCodeKey → const String
- SMS code key.
- tmpUserEmailKey → const String
- Key for temporary email address.
- tmpUserPhoneNumberKey → const String
- Key for temporary phone number.
- userEmailKey → const String
- User email key.
- userIdKey → const String
- User ID key.
- userNameKey → const String
- User name key.
- userPasswordKey → const String
- User password key.
- userPhoneNumberKey → const String
- User phone number key.
- userPhotoURLKey → const String
- User photo URL key.
- verifiedKey → const String
- Key to authenticated or not.