Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
digitalascetic/base-user / Service / UserPasswordEncoderService.php
Size: Mime:
<?php


namespace DigitalAscetic\BaseUserBundle\Service;


use Symfony\Component\PasswordHasher\Hasher\UserPasswordHasherInterface;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;

class UserPasswordEncoderService
{
    const SERVICE_NAME = 'digital_ascetic_base_user.service.password_encoder';

    /** @var UserPasswordHasherInterface */
    private UserPasswordHasherInterface $userPasswordHasher;

    /**
     * UserPasswordEncoderService constructor.
     * @param UserPasswordHasherInterface $userPasswordEncoder
     */
    public function __construct(UserPasswordHasherInterface $userPasswordHasher)
    {
        $this->userPasswordHasher = $userPasswordHasher;
    }

    public function encodeUserPassword(PasswordAuthenticatedUserInterface $user, $newPassword): string
    {
        return $this->userPasswordHasher->hashPassword($user, $newPassword);
    }
}