AuthSessionManager class

Stores and reads simple browser-side auth session state.

Constructors

AuthSessionManager({String tokenKey = 'auth.token', String userKey = 'auth.user', BrowserStorage storage = localStorage})
Creates a session manager using browser storage keys.
const

Properties

current → AuthSessionSnapshot?
The current session snapshot, or null when logged out.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isLoggedIn → bool
Whether a non-empty token is currently stored.
no setter
role → String?
The current user's role when available.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
storage → BrowserStorage
Browser storage backend used by this session manager.
final
token → String?
The current token, or null when no usable token is stored.
no setter
tokenKey → String
Storage key used for the authentication token.
final
user → Map<String, dynamic>
The current user payload, or an empty map when none is stored.
no setter
userKey → String
Storage key used for the serialized user payload.
final

Methods

clear() → void
Clears the stored token and user payload.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save({required String token, Map<String, dynamic> user = const {}}) → void
Saves a token and optional user payload to browser storage.
toString() → String
A string representation of this object.
inherited
updateUser(Map<String, dynamic> user) → void
Replaces the stored user payload without changing the token.

Operators

operator ==(Object other) → bool
The equality operator.
inherited