NanoAuthRepository<Session extends NanoEntity> class
abstract
An abstract repository for handling user authentication, session persistence, and token lifecycle management.
Constructors
- NanoAuthRepository({String tokenStorageKey = defaultTokenStorageKey, String refreshTokenStorageKey = defaultRefreshTokenStorageKey, NanoHttpClient? client, NanoStorage? storage})
-
Creates a NanoAuthRepository instance.
const
Properties
- client → NanoHttpClient
-
The HTTP client used to perform requests.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isAuthenticated → bool
-
Checks if a non-empty access token is present in storage.
no setter
- refreshToken → String?
-
Retrieves the current stored refresh token.
no setter
- refreshTokenStorageKey → String
-
Key used to store/retrieve the refresh token in storage.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- storage → NanoStorage?
-
The active storage store.
no setter
- token → String?
-
Retrieves the current stored access token.
no setter
- tokenStorageKey → String
-
Key used to store/retrieve the authentication access token in storage.
final
Methods
-
clearSession(
) → void - Clears stored authentication and refresh tokens from storage.
-
logout(
) → Future< void> - Logs out the user and clears the current session.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refreshSession(
) → Future< bool> - Refreshes the active session using the stored refreshToken.
-
restoreSession(
) → Future< Session?> - Restores and validates the current active user session.
-
saveToken(
String token, {String? refreshToken}) → void -
Saves the access token (and optionally
refreshToken) to storage. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultRefreshTokenStorageKey → const String
- Default storage key for refresh tokens.
- defaultTokenStorageKey → const String
- Default storage key for authentication access tokens.