updatePassword static method

Future<AuthResult> updatePassword(
  1. String newPassword, [
  2. String? oldPassword,
  3. String? passwordEncryptType
])

update current user's password.

Implementation

static Future<AuthResult> updatePassword(String newPassword,
    [String? oldPassword, String? passwordEncryptType]) async {
  Map map = {};
  map.putIfAbsent('newPassword',
      () => Util.encrypt(newPassword, encryptType: passwordEncryptType));
  if (oldPassword != null) {
    map.putIfAbsent('oldPassword',
        () => Util.encrypt(oldPassword, encryptType: passwordEncryptType));
  }
  if (passwordEncryptType != null) {
    map.putIfAbsent('passwordEncryptType', () => passwordEncryptType);
  }
  final Result result =
      await post('/api/v3/update-password', jsonEncode(map));
  AuthResult authResult = AuthResult(result);
  return authResult;
}