AuthRepository class
The repository responsible for authentication state, login, logout, and startup auth resolution.
Coordinates AuthService, Fresh, SecureStorage, and UserRepository to produce a stream of AuthenticationStatus events consumed by AuthenticationBloc. Also listens to AuthFailureNotifier to force a logout when the network layer revokes the session.
The constructor immediately subscribes to auth-failure events — callers must call dispose to cancel these subscriptions and close the status stream.
Constructors
-
AuthRepository({required AuthService authService, required Fresh<
AuthTokenModel> fresh, required SecureStorage secureStorage, required UserRepository userRepository, required AuthFailureNotifier authFailureNotifier, required ToastService toastService, required AppLogger logger}) - Creates an AuthRepository and subscribes to auth-failure notifications.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
statusChanges
→ Stream<
AuthenticationStatus> -
A stream that emits an AuthenticationStatus whenever auth state changes.
no setter
Methods
-
checkSessionOnResume(
) → Future< bool> - Validates the stored session token when the app returns from background.
-
dispose(
) → Future< void> - Cancels auth-failure subscriptions, closes the status stream, and disposes AuthFailureNotifier.
-
login(
{required String email, required String password}) → Future< void> -
Authenticates the user with
emailandpassword. -
logout(
) → Future< void> - Signs the user out by calling the logout endpoint and cleaning up local auth data.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
resolveInitialStatus(
) → Future< (AuthenticationStatus, UserModel?)> - Resolves the initial AuthenticationStatus and user at startup.
-
resolveUser(
{bool notify = false}) → Future< UserModel> - The current authenticated user, fetched from the API or cache.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited