LittlefishSessionManager class

Note: Session tokens refreshes are still needed but the token expiration is now extended to basically be a lifetime token.

Constructors

LittlefishSessionManager()
factory

Properties

activeSession → AuthUserSession?
no setter
analyticsService → AnalyticsService
no setter
authService → AuthService
no setter
baseSession → AuthUserSession?
The base (auth) user's session. Null until first sign-in.
no setter
configService → ConfigService
no setter
core ↔ LittleFishCore
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
isBaseUserAdmin bool
Whether the base (Firebase-authenticated) user has admin privileges. Returns false if no base session exists yet.
no setter
isBaseUserOwner bool
Whether the base (Firebase-authenticated) user is the business owner. Returns false if no base session exists yet.
no setter
isInitialized bool
Whether the session manager has been initialized.
no setter
logger → LoggerService
no setter
monitoringService → MonitoringService<dynamic, MonitoringHttpMetric, MonitoringTrace>
no setter
onSessionChanged Stream<AuthUserSession?>
listens to active session changes
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sessionService AuthSessionService
no setter
tokenHelper TokenHelper
no setter

Methods

captureBaseSession(AuthUserSession session) → void
Captures the given session as the base (auth) user session if one has not already been set. Called after every sign-in so the original admin session is preserved across user switches.
clearBaseSession() → void
Clears the base session snapshot. Called on sign-out.
createSession(String userId, {String? mid, String? businessId, String? pin}) Future<AuthUserSession>
Creates a new session via the service and stores it in memory. pin Optional PIN for session creation when PIN verification is required.
deleteAllSessions({required String businessId, String? mid}) Future<void>
Deletes all sessions from the server and clears them from memory.
deleteSession(String userId) Future<void>
Deletes a single user's session from the server and memory.
getActiveSession() Future<AuthUserSession?>
Retrieves the currently active session, or null if no valid session exists.
getAllSessions() List<AuthUserSession>
Returns all in-memory sessions from the local repository.
getOrCreateSession({required String userId, String? mid, String? businessId, bool refresh = false, String? pin}) Future<AuthUserSession>
Retrieves a session from memory, or fetches/creates it from the server.
getSessionByUserId(String userId, {bool force = false}) Future<AuthUserSession?>
Retrieves a session by userId, optionally forcing a fetch from the server.
getSessionStatus(AuthUserSession session) → AuthSessionStatus
initialise() Future<void>
isSessionExpired(AuthUserSession session) bool
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
refreshCurrentSession() Future<AuthUserSession>
Deprecated Tries to refresh the currently active session. If no active session exists, throws an error.
refreshSession(String userId) Future<AuthUserSession>
Deprecated Refreshes the session for the given userId by fetching a new session from the server.
refreshSessionIfExpiring(AuthUserSession existingSession) Future<AuthUserSession>
Deprecated Refreshes the session if it is expiring soon or expired. Returns the valid session (refreshed or existing).
restoreBaseSession(AuthUserSession session) → void
Restores a previously captured base session. Used to recover admin state after a failed switchSession so that isBaseUserAdmin does not permanently return false.
switchSession({required String userId, String? mid, String? businessId, bool refresh = false, String? pin}) Future<AuthUserSession>
Switches the activeSession to the one associated with userId and optionally with the mid and businessId.
toString() String
A string representation of this object.
inherited
validateSession(AuthUserSession? session, {bool refreshOnExpiring = true}) Future<void>
Validates that the session is valid.

Operators

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

Static Properties

instance LittlefishSessionManager
final