resetPasswordByPhone static method

Future<AuthResult> resetPasswordByPhone(
  1. String phoneNumber,
  2. String passCode,
  3. String password, [
  4. String? phoneCountryCode,
  5. String? passwordEncryptType,
])

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);
  }
}