updatePassword method

Future<UpdatePasswordSuccess> updatePassword(
  1. String idToken,
  2. String password
)

Implementation

Future<UpdatePasswordSuccess> updatePassword(String idToken, String password) async {
  final url = Uri.parse('$firebaseUrl/accounts:update?key=$_firebaseKey');
  final jsonRequestBody = jsonEncode({
    'idToken': idToken,
    'password': password,
    'returnSecureToken': true,
  });
  final response = await http.post(
    url,
    headers: {'Content-Type': 'application/json'},
    body: jsonRequestBody,
  );

  if (response.statusCode >= 200 && response.statusCode < 300) {
    return UpdatePasswordSuccess.fromJson(jsonDecode(response.body));
  } else {
    throw WepinError(WepinErrorCode.failedPasswordSetting, 'code: ${response.statusCode} , body: ${response.body}');
  }
}