resetPasswordByPhone static method
reset password by phone number and an SMS code.
Implementation
static Future<AuthResult> resetPasswordByPhone(
String phoneNumber, String passCode, String password,
[String? phoneCountryCode, String? passwordEncryptType]) async {
Map map = {};
map.putIfAbsent('phoneNumber', () => phoneNumber);
map.putIfAbsent('passCode', () => passCode);
if (phoneCountryCode != null) {
map.putIfAbsent('phoneCountryCode', () => phoneCountryCode);
}
var body = {'verifyMethod': 'PHONE_PASSCODE', 'phonePassCodePayload': map};
final Result tokenResult =
await post('/api/v3/verify-reset-password-request', jsonEncode(body));
if (tokenResult.statusCode == 200) {
var resultBody = {
'passwordResetToken': tokenResult.data['passwordResetToken'],
'password': Util.encrypt(password, encryptType: passwordEncryptType)
};
final Result result =
await post('/api/v3/reset-password', jsonEncode(resultBody));
AuthResult authResult = AuthResult(result);
return authResult;
} else {
return AuthResult(tokenResult);
}
}