. */ define("headless", true); require_once(dirname(__DIR__) . "/auth.php"); // sets $user require_once(ROOT_DIR . "/helpers/utils.php"); $login = isset($_REQUEST['login']) ? trim($_REQUEST['login']) : NULL; $oldpass = isset($_REQUEST['oldpass']) ? $_REQUEST['oldpass'] : NULL; $pass = isset($_REQUEST['pass']) ? $_REQUEST['pass'] : NULL; if (empty($pass)) { uUtils::exitWithError("Empty password"); } if ($user->isAdmin && !empty($login)) { // different user, only admin $passUser = new uUser($login); if (!$passUser->valid) { uUtils::exitWithError("User unknown"); } } else { // current user $passUser = $user; if (!$passUser->validPassword($oldpass)) { uUtils::exitWithError("Wrong old password"); } } if ($passUser->setPass($pass) === false) { uUtils::exitWithError("Server error"); } uUtils::exitWithSuccess(); ?>