UAuth class abstract

Login session on top of ULocalStorage: JWT expiry, one-at-a-time token refresh, sign-out. UHttpClient uses it automatically. if (UAuth.isSignedIn) …

Constructors

UAuth()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

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

Static Properties

canRefresh → bool
True when a valid refresh token can renew the session.
no setter
epoch → int
Counter bumped on every login/logout; lets requests started before a logout ignore their result.
no setter
hasRefreshToken → bool
True when a refresh token is saved.
no setter
isRefreshTokenExpired → bool
True when the saved refresh token has expired.
no setter
isSessionEnded → bool
True after the server rejected the refresh token (user was signed out).
no setter
isSignedIn → bool
True when a token exists and is valid or can be refreshed. home: UAuth.isSignedIn ? HomePage() : LoginPage()
no setter

Static Methods

accessTokenExpiresAt() → DateTime?
Expiry read from the JWT "exp" claim; null when the token is not a JWT.
clear() → Future<void>
Deletes only the tokens and user id.
diagnostics() → String
One-line dump of the session state for logs.
ensureFreshToken() → Future<void>
Refreshes the access token first when it is (nearly) expired; UHttpClient calls it before each request.
handleAuthFailure() → Future<void>
Signs out once and calls UHttpClient.onAuthFailed (e.g. to show the login page).
isAccessTokenExpired() → bool
True when the access token expires within 30 seconds.
isTokenIssuingEndpoint(String endpoint) → bool
True for login/register/refresh endpoints (they never need a token).
onTokensIssued() → void
Call after saving new tokens; resets the session-ended flag.
refresh() → Future<bool>
Refreshes the tokens now; parallel calls share one request. Returns true on success.
signOut() → Future<void>
Signs out: clears storage and files but keeps the language and theme. await UAuth.signOut(); UNavigator.offAll(LoginPage())