AuthResult class
Represents the result of an authentication operation
Contains either successful authentication data (tokens and user info) or error information if the authentication failed.
Constructors
-
AuthResult.cancelled({String message = 'Authentication was cancelled by the user', Map<
String, dynamic> metadata = const {}}) -
Creates a cancelled authentication result (user cancelled the flow)
factory
-
AuthResult.failure({required FrappeAuthException error, Map<
String, dynamic> metadata = const {}}) -
Creates a failed authentication result
factory
-
AuthResult.success({required UserInfo userInfo, required TokenResponse tokens, Map<
String, dynamic> metadata = const {}}) -
Creates a successful authentication result
factory
Properties
- cancelled → bool
-
Whether the user cancelled the authentication
final
- error → FrappeAuthException?
-
Error information (only available on failure)
final
- errorCode → String?
-
Gets the error code if authentication failed
no setter
- errorMessage → String?
-
Gets the error message if authentication failed
no setter
- friendlyErrorMessage → String
-
Gets a user-friendly error message
no setter
- hashCode → int
-
The hash code for this object.
no setteroverride
- isCancelled → bool
-
no setter
- isConfigurationError → bool
-
Whether the authentication failed due to configuration issues
no setter
- isFailure → bool
-
no setter
- isNetworkError → bool
-
Whether the authentication failed due to a network error
no setter
- isSuccess → bool
-
Helper getters for easier result checking
no setter
- isTokenError → bool
-
Whether the authentication failed due to invalid tokens
no setter
-
metadata
→ Map<
String, dynamic> -
Additional metadata about the authentication process
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- success → bool
-
Whether the authentication was successful
final
- tokens → TokenResponse?
-
Token response (only available on success)
final
- userInfo → UserInfo?
-
User information (only available on success)
final
- wasCancelled → bool
-
Whether the authentication was cancelled by the user (legacy method)
no setter
Methods
-
copyWith(
{Map< String, dynamic> ? metadata}) → AuthResult - Creates a copy of this AuthResult with updated metadata
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFailure<
T> (T callback(FrappeAuthException error)) → T? - Executes a callback if authentication failed
-
onSuccess<
T> (T callback(UserInfo userInfo, TokenResponse tokens)) → T? - Executes a callback if authentication was successful
-
toString(
) → String -
A string representation of this object.
override
-
when<
T> ({required T success(UserInfo userInfo, TokenResponse tokens), required T failure(FrappeAuthException error)}) → T - Executes appropriate callback based on result
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override