$errorFields[] = 'userID'; } if (!isset($_GET['password']) || !$adminService->isStringR($_GET['password'])) { $errorFields[] = 'password'; } if (!isset($_GET['passwordConfirm']) || !$adminService->isStringR($_GET['passwordConfirm'])) { $errorFields[] = 'passwordConfirm'; } if (count($errorFields)) { throw new Exception('validation'); } if ($_GET['passwordConfirm'] !== $_GET['password']) { $errorFields[] = 'password'; $errorFields[] = 'passwordConfirm'; throw new Exception('validation'); } $adminService->updateUserPassword($_GET['userID'], $_GET['password']); } else { throw new Exception('This function does not exist.'); } } catch (Exception $e) { if ($e->getMessage() === 'validation') { $ajaxReturn['validation'] = true; $ajaxReturn['fields'] = $errorFields; } else { $adminService->logError($e->getMessage()); $ajaxReturn['error'] = true; $ajaxReturn['message'] = $e->getMessage(); } } echo json_encode($ajaxReturn);