CoffeeAuthRequest<T extends CoffeeModel> class
CoffeeAuthRequest
handles authentication-related HTTP requests.
This class provides methods to perform sign-in, password change, and user data retrieval operations using HTTP requests.
Example:
final authRequest = CoffeeAuthRequest(
baseEndpoint: 'https://api.example.com',
httpClient: http.Client(),
fromJson: (json) => User.fromJson(json),
);
Constructors
-
CoffeeAuthRequest({required String baseEndpoint, required Client httpClient, required T fromJson(Map<
String, dynamic> )}) -
Creates an instance of
CoffeeAuthRequest
.
Properties
- currentUser ↔ T?
-
getter/setter pair
- currentUserLock ↔ bool
-
getter/setter pair
-
fromJson
→ T Function(Map<
String, dynamic> ) -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
Provides a CoffeeSocialRequest instance to handle social authentication requests.
no setter
Methods
-
authenticateUser(
String token, T user) → void - Authenticates the user by setting the JWT token and logged-in user data.
-
changePassword(
String newPassword) → Future< T> - Changes the password of the current user.
-
getAuthInfo(
) → Future< T?> - Retrieves authentication information of the user.
-
getCurrentUser(
) → Future< T?> - Retrieve the current logged-in user data.
-
getStorageValue(
String key) → Future - Retrieve a value from the storage, based on a key and the logged-in user.
-
isLoggedIn(
) → Future< bool> - This method checks if a token exists and if the current user data is available, indicating that a user is logged in.
-
logout(
) → void - Logs out the current user.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
refreshCurrentUser(
) → Future< T?> - Refreshes the current logged-in user data.
-
setStorageValue(
String key, dynamic value) → Future< void> - Set a value in the storage, associated with a key and the logged-in user.
-
setUserPropertyByPath(
String propertyPath, dynamic newValue) → Future< void> - Sets a property value for the current user by a given path within their JSON data.
-
signInWithCode(
String url, String code) → Future< T> - Authenticates a user using a code.
-
signInWithLoginPassword(
{required String login, required String password}) → Future< T> - Authenticates a user using login and password.
-
toString(
) → String -
A string representation of this object.
inherited
-
withQueryParameter(
String key, String value) → CoffeeAuthRequest< T> -
Chains a query parameter to the request made by the
getCurrentUser
method.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited