From 9a36d1b45fe4be2c173096e4c73dc7a312e0854f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 10 Oct 2018 12:33:15 +0200 Subject: [PATCH 1/2] Fix and improve JSON login docs --- security/json_login_setup.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/security/json_login_setup.rst b/security/json_login_setup.rst index 3d1c12ffd40..4b7a51413be 100644 --- a/security/json_login_setup.rst +++ b/security/json_login_setup.rst @@ -80,6 +80,12 @@ path: */ public function loginAction(Request $request) { + $user = $this->getUser(); + + return $this->json(array( + 'username' => $user->getUsername(), + 'roles' => $user->getRoles(), + )); } } From c9ae00ab9b77b61e5864dff9fc037d9c35f50b4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Wed, 10 Oct 2018 12:40:32 +0200 Subject: [PATCH 2/2] Update json_login_setup.rst --- security/json_login_setup.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/security/json_login_setup.rst b/security/json_login_setup.rst index 4b7a51413be..da142c3f5a6 100644 --- a/security/json_login_setup.rst +++ b/security/json_login_setup.rst @@ -123,11 +123,11 @@ path: return $routes; -Don't let this empty controller confuse you. When you submit a ``POST`` request -to the ``/login`` URL with the following JSON document as the body, the security -system intercepts the requests. It takes care of authenticating the user with -the submitted username and password or triggers an error in case the authentication -process fails: +When you submit a ``POST`` request to the ``/login`` URL with the following JSON document as the body, +the security system intercepts the requests. +It takes care of authenticating the user with the submitted username and password or triggers an error +in case the authentication process fails. +If the authentication is successful, the controller defined earlier will be executed. .. code-block:: json