Exemple #1
0
 /**
  * Private helper method for sValidateStep1
  * Validates password data and account mode
  *
  * @param $edit
  * @param $postData
  * @param $register
  * @param $encoderName
  * @param $sErrorMessages
  * @param $sErrorFlag
  * @return array Error data
  */
 private function validateStep1Password($edit, &$postData, &$register, &$encoderName, &$sErrorMessages, &$sErrorFlag)
 {
     // Check account mode and password
     if (!$postData["skipLogin"] || $edit) {
         if (!$edit || (isset($postData["password"]) || isset($postData["passwordConfirmation"]))) {
             // Validate password
             if (strlen(trim($postData["password"])) == 0 || !$postData["password"] || strlen($postData["password"]) < $this->config->get('sMINPASSWORD')) {
                 $sErrorMessages[] = $this->snippetManager->getNamespace("frontend")->get('RegisterPasswordLength', '', true);
                 $sErrorFlag["password"] = true;
                 $sErrorFlag["passwordConfirmation"] = true;
             } elseif (isset($postData["passwordConfirmation"]) && $postData["password"] != $postData["passwordConfirmation"]) {
                 $sErrorMessages[] = $this->snippetManager->getNamespace("frontend")->get('AccountPasswordNotEqual', 'The passwords are not equal', true);
                 $sErrorFlag["password"] = true;
                 $sErrorFlag["passwordConfirmation"] = true;
             }
         }
         $register["auth"]["accountmode"] = "0";
         // Setting account mode to ACCOUNT
     } else {
         // Enforce the creation of an md5 hashed password for anonymous accounts
         $postData["password"] = md5(uniqid(rand()));
         $encoderName = 'md5';
         $register["auth"]["accountmode"] = "1";
         // Setting account mode to NO_ACCOUNT
     }
     $this->session->offsetSet('sRegister', $register);
     // Check current password
     $accountPasswordCheck = $this->config->offsetGet('accountPasswordCheck');
     if ($edit && !empty($accountPasswordCheck)) {
         $password = $postData["currentPassword"];
         $current = $this->session->offsetGet('sUserPassword');
         $snippet = $this->snippetManager->getNamespace("frontend");
         if (empty($password) || !$this->passwordEncoder->isPasswordValid($password, $current, $encoderName)) {
             $sErrorFlag['currentPassword'] = true;
             if (isset($postData["password"])) {
                 $sErrorFlag['password'] = true;
             } else {
                 $sErrorFlag['email'] = true;
             }
             $sErrorMessages[] = $snippet->get('AccountCurrentPassword', 'Das aktuelle Passwort stimmt nicht!', true);
         }
     }
 }