Skip to content

Commit

Permalink
bug #3478 Update custom_password_authenticator.rst (piotras-s)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.4 branch.

Discussion
----------

Update custom_password_authenticator.rst

Correct me if I am wrong... but because we are passing here ```username``` as first argument to ```UsernamePasswordToken```, when one would like to use method ```getUser()``` from base ```Controller```:
```
...
if (!$this->container->has('security.context')) {
            throw new \LogicException('The SecurityBundle is not registered in your application.');
        }

        if (null === $token = $this->container->get('security.context')->getToken()) {
            return null;
        }

        if (!is_object($user = $token->getUser())) {
            return null;
        }

        return $user;
...
```
it will fail to get actually logged in user and return null.

Commits
-------

18657aa Update custom_password_authenticator.rst
  • Loading branch information
weaverryan committed Feb 1, 2014
2 parents a171700 + 18657aa commit 6d34aa6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cookbook/security/custom_password_authenticator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ the user::
}

return new UsernamePasswordToken(
$user->getUsername(),
$user,
$user->getPassword(),
$providerKey,
$user->getRoles()
Expand Down

0 comments on commit 6d34aa6

Please # to comment.