AuthCheckTask class
A StartupTask that resolves the initial authentication state and seeds AuthenticationBloc.
Runs in StartupPhase.userAndSession and orchestrates a four-step sequence:
- Calls AuthRepository.resolveInitialStatus, which inspects the stored
token and fetches the user. There are five possible outcomes:
- No stored token → AuthenticationStatus.unauthenticated.
- Token present but expired → clears storage, AuthenticationStatus.unauthenticated.
- Valid token, user fetch succeeds → AuthenticationStatus.authenticated with user.
- Valid token, user fetch returns 401/403 → clears storage, AuthenticationStatus.unauthenticated.
- Valid token, other network failure → AuthenticationStatus.authenticated with cached user (or UserModel.empty if no cache exists).
- Adds StartupAuthResolved to AuthenticationBloc with the resolved status and user.
- Waits for the bloc to leave AuthenticationStatus.unknown, ensuring the startup result is fully processed before live listening begins.
- Adds StartLiveListening to activate the runtime auth and user streams.
- Inheritance
-
- Object
- StartupTask
- AuthCheckTask
Constructors
- AuthCheckTask({required AuthRepository authRepository, required AuthenticationBloc authenticationBloc, required AppLogger logger})
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → StartupTaskId
-
A unique identifier for this task, used for logging and ordering.
no setteroverride
- label → String
-
A short human-readable description shown on the splash screen while this task runs.
no setteroverride
- phase → StartupPhase
-
The startup phase this task belongs to.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
execute(
{void onSubProgress(double subFraction)?}) → Future< void> -
Performs the startup work for this task.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited