/** * Generates new hash * @static * @return string */ private static function createHash() { do { $hash = hash(LostPW::HASH_ALGO, microtime() . uniqid()); } while (LostPW::hashExists($hash)); return $hash; }
public function lostpw_check() { $hash = $this->getParam('hash', ''); if (!LostPW::hashExists($hash)) { System::getSession()->setData('errorMsg', System::getLanguage()->_('HashNotFound')); System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index')); } $password = Utils::getPOST('password', ''); $password2 = Utils::getPOST('password2', ''); $errorMsg = ''; if (Utils::getPOST('submit', false) != false) { if (strlen($password) < PASSWORD_MIN_LENGTH) { $errorMsg = sprintf(System::getLanguage()->_('PasswordMinLength'), PASSWORD_MIN_LENGTH); } else { if ($password != $password2) { $errorMsg = System::getLanguage()->_('ErrorInvalidPasswords'); } else { LostPW::resetPassword($hash, $password); System::getSession()->setData('successMsg', System::getLanguage()->_('LostPWSuccess')); System::forwardToRoute(Router::getInstance()->build('BrowserController', 'index')); } } } $smarty = new Template(); $smarty->assign('title', System::getLanguage()->_('LostPW')); $smarty->assign('successMsg', ''); $smarty->assign('form_url', Router::getInstance()->build('AuthController', 'lostpw_check', array('hash' => $hash))); $smarty->assign('errorMsg', $errorMsg); $smarty->requireResource('auth'); $smarty->display('auth/lostpw.newpw.tpl'); }