changePassword method
Changes a user password.
Uses the existing password password
to
change the account password to newPassword
with the access token obtained from logging in
or extending a session.
Implementation
Future<void> changePassword(
String password, String newPassword, String accessToken) async {
final uri = _urlBase.getPath(_passwordChangeEndpoint);
final body = await JsonIsolate().encodeJson({
'password': password,
'newpassword': newPassword,
});
final resp = await put(
uri,
body: body,
headers: {
URLBase.authHeader: accessToken,
},
);
final bodyResp = await JsonIsolate().decodeJson(resp.body);
if (resp.statusCode != 200) {
if (bodyResp['error_code'] == 101009) {
throw InvalidCredentialsException();
}
throw bodyResp['description'];
}
}