changePassword method
Changes the password of the current user.
Sends a PUT request to the "user/changepassword" endpoint with the new password.
newPassword
: The new password for the user.
Returns a Future
that completes with the current user data.
Implementation
Future<T> changePassword(String newPassword) async {
final url = Uri.parse(CoffeeUtil.concatUrl(_baseEndpoint, 'user/changepassword'));
final response = await _httpClient.put(url, headers: {
HttpHeaders.authorizationHeader: CoffeeStorage.getJwtToken()
}, body: CoffeeUtil.convertModelToFormData(newPassword));
CoffeeUtil.handleErrorMessage(response);
return currentUser!;
}