Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DX] New service to simplify password encoding #11299

Closed
@weaverryan

Description

@weaverryan

Encoding a user's password currently looks like this:

$encoder = $this->container->get('security.encoder_factory')
    ->getEncoder($user)
;

$encoded = $encoder->encodePassword($plainPassword, $user->getSalt());

$user->setPassword($encoded);

I'd like to make this easier. How about:

$encoded = $this->container->get('security.password_encoder')
    ->encodePassword($user, $plainPassword);

$user->setPassword($encoded);

The security.password_encoder would be a new service. It would use the $user to get the correct encoder and the getSalt method (which is on UserInterface to get the salt. Done! Hopefully I'm not overlooking anything :).

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    DXDX = Developer eXperience (anything that improves the experience of using Symfony)Security

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions