| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /inetpub/wwwroot/Topogeo/ojs/classes/user/form/ |
Upload File : |
<?php
/**
* @file classes/user/form/LoginChangePasswordForm.inc.php
*
* Copyright (c) 2003-2012 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class LoginChangePasswordForm
* @ingroup user_form
*
* @brief Form to change a user's password in order to login.
*/
// $Id$
import('lib.pkp.classes.form.Form');
class LoginChangePasswordForm extends Form {
/**
* Constructor.
*/
function LoginChangePasswordForm() {
parent::Form('user/loginChangePassword.tpl');
$site =& Request::getSite();
// Validation checks for this form
$this->addCheck(new FormValidatorCustom($this, 'oldPassword', 'required', 'user.profile.form.oldPasswordInvalid', create_function('$password,$form', 'return Validation::checkCredentials($form->getData(\'username\'),$password);'), array(&$this)));
$this->addCheck(new FormValidatorLength($this, 'password', 'required', 'user.register.form.passwordLengthTooShort', '>=', $site->getMinPasswordLength()));
$this->addCheck(new FormValidator($this, 'password', 'required', 'user.profile.form.newPasswordRequired'));
$this->addCheck(new FormValidatorCustom($this, 'password', 'required', 'user.register.form.passwordsDoNotMatch', create_function('$password,$form', 'return $password == $form->getData(\'password2\');'), array(&$this)));
$this->addCheck(new FormValidatorPost($this));
}
/**
* Display the form.
*/
function display() {
$templateMgr =& TemplateManager::getManager();
$site =& Request::getSite();
$templateMgr->assign('minPasswordLength', $site->getMinPasswordLength());
parent::display();
}
/**
* Assign form data to user-submitted data.
*/
function readInputData() {
$this->readUserVars(array('username', 'oldPassword', 'password', 'password2'));
}
/**
* Save new password.
* @return boolean success
*/
function execute() {
$userDao =& DAORegistry::getDAO('UserDAO');
$user =& $userDao->getUserByUsername($this->getData('username'), false);
if ($user != null) {
if ($user->getAuthId()) {
$authDao =& DAORegistry::getDAO('AuthSourceDAO');
$auth =& $authDao->getPlugin($user->getAuthId());
}
if (isset($auth)) {
$auth->doSetUserPassword($user->getUsername(), $this->getData('password'));
$user->setPassword(Validation::encryptCredentials($user->getId(), Validation::generatePassword())); // Used for PW reset hash only
} else {
$user->setPassword(Validation::encryptCredentials($user->getUsername(), $this->getData('password')));
}
$user->setMustChangePassword(0);
$userDao->updateObject($user);
return true;
} else {
return false;
}
}
}
?>