Auth class
Authentication class for managing user sessions.
Supports multiple named sessions for different auth contexts (e.g., user auth, device auth, etc.).
Learn more: https://nylo.dev/docs/7.x/authentication
Example:
// Default session (user)
await Auth.authenticate(data: user);
Auth.data(field: 'token');
// Named session (device)
await Auth.authenticate(data: device, session: 'device');
Auth.data(session: 'device');
Constructors
- Auth()
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 Methods
-
authenticate(
{dynamic data, String? session}) → Future< void> - Authenticate and store session data.
-
data(
{String? field, String? session}) → dynamic - Get auth data for a session.
-
deviceId(
) → Future< String> - Get or generate a unique device ID.
-
isAuthenticated(
{String? session}) → Future< bool> - Check if a session is authenticated.
-
key(
[String? session]) → String - Get the storage key for a session.
-
logout(
{String? session}) → Future< void> - Logout from a specific session.
-
logoutAll(
{List< String> sessions = const []}) → Future<void> - Logout from all known sessions.
-
set(
dynamic update(dynamic data), {String? session}) → Future< void> - Update the auth data for a session.
-
syncAllToBackpack(
{List< String> sessions = const []}) → Future<void> - Sync all sessions to backpack.
-
syncToBackpack(
{String? session}) → Future< void> - Sync auth data from storage to backpack for a session.
Constants
- defaultSession → const String
- The default session name.