Skip to content

Commit

Permalink
bug #4744 [Book][Security] Update code example to fit description (xe…
Browse files Browse the repository at this point in the history
…laris)

This PR was merged into the 2.6 branch.

Discussion
----------

[Book][Security] Update code example to fit description

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | >=2.6
| Fixed tickets |

The text mentions an `$encoder` object, which wasn't created in the code example.

In addition, I think the paragraph
> The ``$encoder`` object also has an ``isPasswordValid`` method, which takes
> the ``User`` object as the first argument and the plain password to check
> as the second argument.

is also applicable to the 2.3 version (https://github.com/symfony/symfony-docs/blob/2.3/book/security.rst#dynamically-encoding-a-password), where the code example already provides an `$encoder` variable. Should I add it there?

Commits
-------

bd34c6b Update code example to fit description
  • Loading branch information
weaverryan committed Jan 4, 2015
2 parents c810c69 + bd34c6b commit b143754
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions book/security.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1174,8 +1174,8 @@ in the following way from a controller::
// whatever *your* User object is
$user = new AppBundle\Entity\User();
$plainPassword = 'ryanpass';
$encoded = $this->container->get('security.password_encoder')
->encodePassword($user, $plainPassword);
$encoder = $this->container->get('security.password_encoder');
$encoded = $encoder->encodePassword($user, $plainPassword);

$user->setPassword($encoded);

Expand Down

0 comments on commit b143754

Please sign in to comment.