/** * Logs in the user if applied login and password is valid. * * @param string $login * @param string $password * @param bool $authenticationMatch * @return mixed eZUser or false */ public static function loginUser($login, $password, $authenticationMatch = false) { $user = self::_loginUser($login, $password, $authenticationMatch); if ($user instanceof eZUser) { $userID = $user->attribute('contentobject_id'); $paex = eZPaEx::getPaEx($userID, true); if ($paex instanceof eZPaEx && $paex->isExpired()) { self::passwordHasExpired($user); return false; } else { self::loginSucceeded($user); return $user; } } else { self::loginFailed($user, $login); return false; } return $user; }
/** * Update current empty paex fields with values get from paex object of * parent of current main node. * * @param bool $forceUpdate * @return true */ function updateFromParent($forceUpdate = false) { $mainNode = eZContentObjectTreeNode::findMainNode($this->attribute('contentobject_id'), true); if (!is_object($mainNode)) { eZDebug::writeDebug('mainNode not found', 'eZPaEx::updateFromParent'); } elseif ($mainNode->attribute('depth') > 1) { $parentMainNodeID = $mainNode->attribute('parent_node_id'); $parentContentObject = eZContentObject::fetchByNodeID($parentMainNodeID); $parentPaex = eZPaEx::getPaEx($parentContentObject->attribute('id')); if ($parentPaex instanceof eZPaEx) { $paexUpdated = false; if (!$this->hasRegexp() || $forceUpdate) { $this->setAttribute('passwordvalidationregexp', $parentPaex->attribute('passwordvalidationregexp')); $paexUpdated = true; } if (!$this->hasLifeTime() || $forceUpdate) { $this->setAttribute('passwordlifetime', $parentPaex->attribute('passwordlifetime')); $paexUpdated = true; } if (!$this->hasNotification() || $forceUpdate) { $this->setAttribute('expirationnotification', $parentPaex->attribute('expirationnotification')); $paexUpdated = true; } if ($paexUpdated) { eZDebug::writeDebug('Paex updated from parent', 'eZPaEx::updateFromParent'); $this->store(); } } } return true; }
} // The forgotPasswdObj was previously validated, fetch the corresponding user object $UserID = $forgotPasswdObj->attribute('user_id'); $user = eZUser::fetch($UserID); $login = $user->attribute("login"); $type = $user->attribute("password_hash_type"); $hash = $user->attribute("password_hash"); $site = $user->site(); if ($newPassword == $confirmPassword) { if (!$user->validatePassword($newPassword)) { // if audit is enabled password changes should be logged eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password not pass standard validation')); $tpl->setVariable('newPasswordNotValidate', true); } else { // Patch for use mbpaex::validatePassword $paex = eZPaEx::getPaEx($UserID); if (!$paex->validatePassword($newPassword)) { // if audit is enabled password changes should be logged eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password not pass PAEX validation')); $tpl->setVariable('newPasswordNotValidate', true); } else { $newHash = $user->createHash($login, $newPassword, $site, $type); if ($newHash == $user->attribute('password_hash')) { // if audit is enabled password changes should be logged eZAudit::writeAudit('user-forgotpassword-fail', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'New and old password are the same')); $tpl->setVariable('newPasswordMustDiffer', true); } else { // if audit is enabled password changes should be logged eZAudit::writeAudit('user-forgotpassword', array('UserID' => $UserID, 'Login' => $login, 'Comment: ' => 'Password changed successfully')); $user->setAttribute("password_hash", $newHash); $user->store();