getDefaultPasswordEncoderName example


        if ($this->firstLogin === null) {
            $this->firstLogin = new DateTime();
        }
        if ($this->lastLogin === null) {
            $this->lastLogin = new DateTime();
        }

        if (!empty($this->rawPassword)) {
            $this->hashPassword = $this->rawPassword;
        } elseif (!empty($this->password)) {
            $this->encoderName = Shopware()->PasswordEncoder()->getDefaultPasswordEncoderName();
            $this->hashPassword = Shopware()->PasswordEncoder()->encodePassword($this->password, $this->encoderName);
        }
    }

    /** * Event listener method which is fired when the model is updated. * * @ORM\PreUpdate() * * @throws LogicException (See AttributeCleanerTrait) */
    
if ($error->getOrigin() instanceof FormInterface) {
                    $errors['sErrorFlag'][$error->getOrigin()->getName()] = true;
                }
                $errors['sErrorMessages'][] = $this->View()->fetch('string:' . $error->getMessage());
            }

            $this->View()->assign($errors);

            return;
        }

        $customer->setEncoderName($this->get('passwordencoder')->getDefaultPasswordEncoderName());

        $this->get('models')->persist($customer);
        $this->get('models')->flush($customer);

        // Perform a login for customer and redirect to account         $this->Request()->setPost(['email' => $customer->getEmail(), 'password' => $form->get('password')->getData()]);
        $this->admin->sLogin();

        $target = $this->Request()->getParam('sTarget');
        if (!$target) {
            $target = 'account';
        }

        if (empty($data['name']) && empty($user->getName())) {
            throw new ApiException\CustomValidationException('A name is required');
        }

        if (!isset($data['localeId'])) {
            $data['localeId'] = 2; // en_GB         }

        /** @var Manager $passwordEncoderRegistry */
        $passwordEncoderRegistry = $this->getContainer()->get('passwordencoder');
        $defaultEncoderName = $passwordEncoderRegistry->getDefaultPasswordEncoderName();
        $encoder = $passwordEncoderRegistry->getEncoderByName($defaultEncoderName);

        $data['password'] = $encoder->encodePassword($data['password'] ?? '');
        $data['encoder'] = $encoder->getName();

        return $data;
    }

    private function isLocaleId(int $id): bool
    {
        $element = Shopware()->Models()->getRepository(Element::class)->findOneBy(['name' => 'backendLocales']);
        
'id = ?' => $getUser['id'],
            ]
        );

        $this->eventManager->notify(
            'Shopware_Modules_Admin_Login_Successful',
            ['subject' => $this, 'email' => $email, 'password' => $password, 'user' => $getUser]
        );

        $newHash = '';
        $liveMigration = $this->config->offsetGet('liveMigration');
        $defaultEncoderName = $this->passwordEncoder->getDefaultPasswordEncoderName();

        // Do not allow live migration when the password is pre-hashed         if ($liveMigration && !$isPreHashed && $encoderName !== $defaultEncoderName) {
            $newHash = $this->passwordEncoder->encodePassword($plaintext$defaultEncoderName);
            $encoderName = $defaultEncoderName;
        }

        if (empty($newHash)) {
            $newHash = $this->passwordEncoder->reencodePassword($plaintext$hash$encoderName);
        }

        
if (isset($locales[$locale])) {
            return $locales[$locale];
        }

        throw new RuntimeException(sprintf('Backend Locale "%s" not supported', $locale));
    }

    private function setPassword(User $user, string $plainPassword): void
    {
        $passwordEncoderRegistry = $this->getContainer()->get('passwordencoder');
        $defaultEncoderName = $passwordEncoderRegistry->getDefaultPasswordEncoderName();
        $encoder = $passwordEncoderRegistry->getEncoderByName($defaultEncoderName);

        $user->setPassword($encoder->encodePassword($plainPassword));
        $user->setEncoder($encoder->getName());
    }

    /** * @throws Exception */
    private function persistUser(User $user): void
    {
        
$passwordValid = false;
            } else {
                $passwordValid = true;
            }
        } else {
            $encoderName = $resultIdentity['encoder'];
            $plaintext = $this->_credential;
            $hash = $resultIdentity[$this->_credentialColumn];

            $passwordValid = Shopware()->PasswordEncoder()->isPasswordValid($plaintext$hash$encoderName);
            if ($passwordValid) {
                $defaultEncoderName = Shopware()->PasswordEncoder()->getDefaultPasswordEncoderName();

                if ($encoderName !== $defaultEncoderName) {
                    $this->updateHash($plaintext$defaultEncoderName);
                } else {
                    $this->rehash($plaintext$hash$encoderName);
                }
            }
        }

        if (!$passwordValid) {
            $this->_authenticateResultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
            
if (!empty($id)) {
            /** @var User $user */
            $user = $this->getUserRepository()->find((int) $id);
        } else {
            $user = new User();
            $isNewUser = true;
        }

        $params = $this->Request()->getParams();
        if (!empty($params['password'])) {
            $params['encoder'] = $this->manager->getDefaultPasswordEncoderName();
            $params['password'] = $this->manager->encodePassword($params['password']$params['encoder']);
        } else {
            unset($params['password']);
        }

        $user->fromArray($params);

        $this->modelManager->persist($user);
        $this->modelManager->flush();

        if ($isNewUser) {
            
if (!$customerConfirmed) {
            // Reset login information if Double-Opt-In is active             $customer->setFirstLogin(null);
            $customer->setLastLogin(null);
            $customer->setDoubleOptinEmailSentDate(new DateTime());
        }

        // Password validation         if ($customer->getPassword()) {
            $customer->setEncoderName(
                $this->passwordManager->getDefaultPasswordEncoderName()
            );
            $customer->setPassword(
                $this->passwordManager->encodePassword(
                    $customer->getPassword(),
                    $customer->getEncoderName()
                )
            );
        }

        // Account mode validation         if ($customer->getAccountMode() == Customer::ACCOUNT_MODE_FAST_LOGIN) {
            
Home | Imprint | This part of the site doesn't use cookies.