/** * Checks if user name does not break logic: * - if user wants to UPDATE his login name, performing check if * user entered correct password * - additionally checking for user name duplicates. This is usually * needed when creating new users. * On any error exception is thrown. * * @param oxUser $oUser active user * @param string $sLogin user preferred login name * @param array $aInvAddress user information * * @return string login name */ public function checkLogin($oUser, $sLogin, $aInvAddress) { $sLogin = isset($aInvAddress['oxuser__oxusername']) ? $aInvAddress['oxuser__oxusername'] : $sLogin; // check only for users with password during registration // if user wants to change user name - we must check if passwords are ok before changing if ($oUser->oxuser__oxpassword->value && $sLogin != $oUser->oxuser__oxusername->value) { // on this case password must be taken directly from request $sNewPass = isset($aInvAddress['oxuser__oxpassword']) && $aInvAddress['oxuser__oxpassword'] ? $aInvAddress['oxuser__oxpassword'] : oxRegistry::getConfig()->getRequestParameter('user_password'); if (!$sNewPass) { // 1. user forgot to enter password $oEx = oxNew('oxInputException'); $oEx->setMessage(oxRegistry::getLang()->translateString('ERROR_MESSAGE_INPUT_NOTALLFIELDS')); return $this->_addValidationError("oxuser__oxpassword", $oEx); } else { // 2. entered wrong password if (!$oUser->isSamePassword($sNewPass)) { $oEx = oxNew('oxUserException'); $oEx->setMessage(oxRegistry::getLang()->translateString('ERROR_MESSAGE_PASSWORD_DO_NOT_MATCH')); return $this->_addValidationError("oxuser__oxpassword", $oEx); } } } if ($oUser->checkIfEmailExists($sLogin)) { //if exists then we do now allow to do that $oEx = oxNew('oxUserException'); $oEx->setMessage(sprintf(oxRegistry::getLang()->translateString('ERROR_MESSAGE_USER_USEREXISTS'), $sLogin)); return $this->_addValidationError("oxuser__oxusername", $oEx); } return $sLogin; }