mirror of
https://github.com/hanskokx/arcane_framework.git
synced 2026-08-15 15:50:26 +02:00
v2.1.0: Added unknown (default) value to the AuthenticationStatus enum
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@ enum SignUpStep {
|
||||
/// This enum has two possible states:
|
||||
/// - `authenticated`: The user is authenticated.
|
||||
/// - `unauthenticated`: The user is not authenticated.
|
||||
/// - `unknown` (default): The authentication status is not yet known.
|
||||
///
|
||||
/// Example:
|
||||
/// ```dart
|
||||
@@ -40,11 +41,17 @@ enum AuthenticationStatus {
|
||||
authenticated,
|
||||
|
||||
/// The user is not authenticated.
|
||||
unauthenticated;
|
||||
unauthenticated,
|
||||
|
||||
/// The authentication status is currently unknown.
|
||||
unknown;
|
||||
|
||||
/// Returns `true` if the current status is `authenticated`.
|
||||
bool get isAuthenticated => this == authenticated;
|
||||
|
||||
/// Returns `true` if the current status is `unauthenticated`.
|
||||
bool get isUnauthenticated => this == unauthenticated;
|
||||
/// Returns `true` if the current status is not `authenticated`.
|
||||
bool get isUnauthenticated => !isAuthenticated;
|
||||
|
||||
/// Returns `true` if the current status is `unknown`.
|
||||
bool get isUnknown => this == unknown;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
static ArcaneAuthenticationService get I => _instance;
|
||||
|
||||
final ValueNotifier<AuthenticationStatus> _notifier =
|
||||
ValueNotifier<AuthenticationStatus>(AuthenticationStatus.unauthenticated);
|
||||
ValueNotifier<AuthenticationStatus>(AuthenticationStatus.unknown);
|
||||
|
||||
/// A `ValueNotifier` that emits the current `AuthenticationStatus`.
|
||||
ValueNotifier<AuthenticationStatus> get notifier => _notifier;
|
||||
@@ -54,7 +54,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
ArcaneAuthInterface? get authInterface => _authInterface;
|
||||
|
||||
/// Returns `true` when the current status is authenticated.
|
||||
bool get isAuthenticated => status == AuthenticationStatus.authenticated;
|
||||
bool get isAuthenticated => status.isAuthenticated;
|
||||
|
||||
final ValueNotifier<bool> _isSignedIn = ValueNotifier<bool>(false);
|
||||
|
||||
@@ -86,7 +86,7 @@ class ArcaneAuthenticationService extends ArcaneService {
|
||||
/// default.
|
||||
Future<void> reset() async {
|
||||
_authInterface = null;
|
||||
_notifier.value = AuthenticationStatus.unauthenticated;
|
||||
_notifier.value = AuthenticationStatus.unknown;
|
||||
_isSignedIn.value = isAuthenticated;
|
||||
_statusController.add(_notifier.value);
|
||||
_signedInController.add(_isSignedIn.value);
|
||||
|
||||
Reference in New Issue
Block a user