AuthManager class
The Auth Manager.
Manages authentication guards for the application. Resolves guards based on configuration.
Built-in Drivers
bearer/sanctum- BearerTokenGuard (default)basic- BasicAuthGuardapi_key- ApiKeyGuard
Usage
// Get the default guard
final guard = Auth.guard();
// Get a specific guard
final apiGuard = Auth.guard('api');
Custom Guards
Auth.manager.extend('firebase', (config) => FirebaseGuard());
- Implementers
Constructors
- AuthManager()
-
Factory constructor returning the singleton.
factory
- AuthManager.forTesting()
- Named constructor for testing — allows subclasses to bypass the singleton.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasUserFactory → bool
-
Whether a user factory has been registered.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
createUser(
Map< String, dynamic> data) → Authenticatable - Create a user instance from data using the registered factory.
-
extend(
String driver, Guard factory(Map< String, dynamic> config)) → void - Register a custom guard driver.
-
forgetGuards(
) → void - Reset all guards (useful for testing).
-
guard(
[String? name]) → Guard - Get a guard instance.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setUserFactory(
Authenticatable factory(Map< String, dynamic> data)) → void - Register the user factory for session restoration.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited