AuthResponse class

Unified authentication response

This class provides a standardized format for authentication responses across all guards and drivers. It ensures consistent API responses and makes it easier to work with authentication data.

Features:

  • Standardized response format
  • Type-safe access to response data
  • Support for different token types
  • User data encapsulation
  • Easy serialization

Constructors

AuthResponse({required Map<String, dynamic> user, String? accessToken, String? refreshToken, String tokenType = 'Bearer', int? expiresIn, int? refreshExpiresIn, Map<String, dynamic>? metadata})
Creates an authentication response
AuthResponse.fromJson(Map<String, dynamic> data)
Creates a response from a map
factory
AuthResponse.tokenOnly({required String accessToken, String? refreshToken, String tokenType = 'Bearer', int? expiresIn, int? refreshExpiresIn})
Creates a token-only response (for refresh operations)
factory
AuthResponse.userOnly(Map<String, dynamic> user)
Creates a user-only response (for stateless authentication)
factory

Properties

accessToken → String?
The access token
final
authorizationHeader → String?
Gets the authorization header value
no setter
expiresIn → int?
Access token expiration time in seconds
final
hashCode → int
The hash code for this object.
no setterinherited
hasTokens → bool
Checks if the response contains tokens
no setter
hasUser → bool
Checks if the response contains user data
no setter
metadata → Map<String, dynamic>?
Additional metadata
final
refreshExpiresIn → int?
Refresh token expiration time in seconds
final
refreshToken → String?
The refresh token (optional)
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
tokenType → String
The token type (e.g., 'Bearer')
final
user → Map<String, dynamic>
The authenticated user data
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() → Map<String, dynamic>
toMap() → Map<String, dynamic>
Converts the response to a map
toString() → String
A string representation of this object.
override

Operators

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