<?php

include __DIR__.'/account.php';

/**
 * Updates the user password.
 **/
class ChangePassword extends Vn\Web\JsonRequest {
	const PARAMS = ['oldPassword', 'newPassword'];

	function run($db) {
		$oldPassword = $_REQUEST['oldPassword'];
		$newPassword = $_REQUEST['newPassword'];

		$db->query('CALL account.myUser_changePassword(#, #)',
			[$oldPassword, $newPassword]);
		Account::sync($db, $_SESSION['user'], $newPassword);
		return TRUE;
	}
}

