From 18657aabc0c3383c8e72736dc55d141ed60c303f Mon Sep 17 00:00:00 2001 From: Piotr Strugacz Date: Wed, 15 Jan 2014 16:49:35 +0100 Subject: [PATCH] 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()```: ``` ... 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; ... ``` from base ```Controller```, it will fail, to get actually logged user and return null. --- cookbook/security/custom_password_authenticator.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/security/custom_password_authenticator.rst b/cookbook/security/custom_password_authenticator.rst index 751beef449c..890c290eae2 100644 --- a/cookbook/security/custom_password_authenticator.rst +++ b/cookbook/security/custom_password_authenticator.rst @@ -66,7 +66,7 @@ the user:: } return new UsernamePasswordToken( - $user->getUsername(), + $user, $user->getPassword(), $providerKey, $user->getRoles()