Commit f477f089 authored by Thibaut Vallee's avatar Thibaut Vallee
Browse files

Merge branch 'release_6.0.6'

parents 3f2016d6 84762034
Loading
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -243,17 +243,25 @@ class UserService implements RechercheIndividuServiceInterface
        return $user;
    }

    /**
     * @param int|null $passwordCost
     */
    public function setPasswordCost(?int $passwordCost): void
    {
        $this->passwordCost = $passwordCost;
    }
    public function changerPassword(User $user, $data) : User
    {
        $password = $data['password1'];

        $bcrypt = new Bcrypt();
//        $bcrypt->setCost($this->userService->getZfcUserOptions()->getPasswordCost());
        $password = $bcrypt->create($user->getPassword());
        if(isset($this->passwordCost)){
            $bcrypt->setCost($this->passwordCost);
        }
        $password = $bcrypt->create($password);
        $user->setPassword($password);
        $user->setPasswordResetToken(null);
        $this->update($user);

        return $user;
    }

+9 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ use Interop\Container\ContainerInterface;
use Laminas\View\Renderer\PhpRenderer;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;
use UnicaenAuthentification\Options\ModuleOptions;
use UnicaenAuthentification\Service\UserContext;
use UnicaenMail\Service\Mail\MailService;
use UnicaenUtilisateur\Entity\Db\User;
@@ -58,6 +59,13 @@ class UserServiceFactory
        $appname = $config['unicaen-app']['app_infos']['nom'];
        $service->setAppname($appname);

        //Récupuration du cout des mots de passe pour le chiffrements
        $options = array_merge(
            $container->get('zfcuser_module_options')->toArray(),
            $container->get('unicaen-auth_module_options')->toArray());
        $moduleOptions = new ModuleOptions($options);
        $service->setPasswordCost($moduleOptions->getPasswordCost());

        return $service;
    }
}
 No newline at end of file