{"action":"created","comment":{"url":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments/64134845","id":64134845,"diff_hunk":"@@ -0,0 +1,197 @@\n+.. index::\n+   single: Security; Login\n+   single: Security; Logout\n+   single: Security; Handler\n+\n+How to Customize the Success and Failure Login Handlers\n+=======================================================\n+\n+After the users successfully log in to your application, they are redirected to\n+the proper URL according to the security configuration options. This is done in\n+the :class:`Symfony\\\\Component\\\\Security\\\\Http\\\\Authentication\\\\DefaultAuthenticationSuccessHandler`\n+class and Symfony defines a similar class called\n+:class:`Symfony\\\\Component\\\\Security\\\\Http\\\\Authentication\\\\DefaultAuthenticationFailureHandler`\n+to handle the login failures.\n+\n+This article explains **how to define your own login handlers** to execute\n+custom logic after the user has logged in successfully or failed to do that.\n+\n+Creating a Success Login Handler\n+--------------------------------\n+\n+First, create a class that implements :class:`Symfony\\\\Component\\\\Security\\\\Http\\\\Authentication\\\\AuthenticationSuccessHandlerInterface`\n+and add your own logic::\n+\n+    namespace AppBundle\\Security;\n+\n+    use Symfony\\Component\\HttpFoundation\\RedirectResponse;\n+    use Symfony\\Component\\Security\\Http\\Authentication\\AuthenticationSuccessHandlerInterface;\n+\n+    class SuccesfulLoginHandler implements AuthenticationSuccessHandlerInterface\n+    {\n+        public function onAuthenticationSuccess(Request $request, TokenInterface $token)\n+        {\n+            // do something...\n+\n+            // you can inherit from the DefaultAuthenticationSuccessHandler\n+            // class to reuse the logic that decides the URL to redirect to\n+            return new RedirectResponse(...);\n+        }\n+    }\n+\n+Then, define a new service for this login handler:\n+\n+.. configuration-block::\n+\n+    .. code-block:: yaml\n+\n+        # app/config/services.yml\n+        services:\n+            app.security.success_login:\n+                class: AppBundle\\Security\\SuccesfulLoginHandler\n+\n+    .. code-block:: xml\n+\n+        <!-- src/AppBundle/Resources/config/services.xml -->","path":"cookbook/security/login_handlers.rst","position":null,"original_position":55,"commit_id":"ecfd34d3d051a674fb1ac9d7072adf6694fbced2","original_commit_id":"c3119e73227c70c939371cf5281daff8460c2b32","user":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"body":"Nice catch! Damn copy+paste :(  Fixed.","created_at":"2016-05-21T13:51:12Z","updated_at":"2016-05-21T13:51:12Z","html_url":"https://github.com/symfony/symfony-docs/pull/6556#discussion_r64134845","pull_request_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556","_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments/64134845"},"html":{"href":"https://github.com/symfony/symfony-docs/pull/6556#discussion_r64134845"},"pull_request":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556"}}},"pull_request":{"url":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556","id":69349688,"html_url":"https://github.com/symfony/symfony-docs/pull/6556","diff_url":"https://github.com/symfony/symfony-docs/pull/6556.diff","patch_url":"https://github.com/symfony/symfony-docs/pull/6556.patch","issue_url":"https://api.github.com/repos/symfony/symfony-docs/issues/6556","number":6556,"state":"open","locked":false,"title":"Added the documentation for the success/failure handlers","user":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"body":"This fixes #4258. I've used 2.7 as the base branch because Fabien said these handlers where not very useful before 2.6.\r\n\r\nIt's still a rough draft. I need help to complete the last section. Thanks!","created_at":"2016-05-09T14:00:49Z","updated_at":"2016-05-21T13:51:12Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a50ab1dac142f0bd3a23862b1c819b8d22988f4b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556/commits","review_comments_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556/comments","review_comment_url":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/symfony/symfony-docs/issues/6556/comments","statuses_url":"https://api.github.com/repos/symfony/symfony-docs/statuses/ecfd34d3d051a674fb1ac9d7072adf6694fbced2","head":{"label":"javiereguiluz:fix_4258","ref":"fix_4258","sha":"ecfd34d3d051a674fb1ac9d7072adf6694fbced2","user":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"repo":{"id":26866700,"name":"symfony-docs","full_name":"javiereguiluz/symfony-docs","owner":{"login":"javiereguiluz","id":73419,"avatar_url":"https://avatars.githubusercontent.com/u/73419?v=3","gravatar_id":"","url":"https://api.github.com/users/javiereguiluz","html_url":"https://github.com/javiereguiluz","followers_url":"https://api.github.com/users/javiereguiluz/followers","following_url":"https://api.github.com/users/javiereguiluz/following{/other_user}","gists_url":"https://api.github.com/users/javiereguiluz/gists{/gist_id}","starred_url":"https://api.github.com/users/javiereguiluz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/javiereguiluz/subscriptions","organizations_url":"https://api.github.com/users/javiereguiluz/orgs","repos_url":"https://api.github.com/users/javiereguiluz/repos","events_url":"https://api.github.com/users/javiereguiluz/events{/privacy}","received_events_url":"https://api.github.com/users/javiereguiluz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/javiereguiluz/symfony-docs","description":"The Symfony2 documentation","fork":true,"url":"https://api.github.com/repos/javiereguiluz/symfony-docs","forks_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/forks","keys_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/teams","hooks_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/hooks","issue_events_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/issues/events{/number}","events_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/events","assignees_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/assignees{/user}","branches_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/branches{/branch}","tags_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/tags","blobs_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/languages","stargazers_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/stargazers","contributors_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/contributors","subscribers_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/subscribers","subscription_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/subscription","commits_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/contents/{+path}","compare_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/merges","archive_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/downloads","issues_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/issues{/number}","pulls_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/labels{/name}","releases_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/releases{/id}","deployments_url":"https://api.github.com/repos/javiereguiluz/symfony-docs/deployments","created_at":"2014-11-19T15:08:31Z","updated_at":"2016-04-05T15:03:48Z","pushed_at":"2016-05-21T13:50:55Z","git_url":"git://github.com/javiereguiluz/symfony-docs.git","ssh_url":"git@github.com:javiereguiluz/symfony-docs.git","clone_url":"https://github.com/javiereguiluz/symfony-docs.git","svn_url":"https://github.com/javiereguiluz/symfony-docs","homepage":"http://symfony.com/doc/current/","size":34971,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"symfony:2.7","ref":"2.7","sha":"9f370c663a01995bf57d623b290433678c550359","user":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"repo":{"id":521583,"name":"symfony-docs","full_name":"symfony/symfony-docs","owner":{"login":"symfony","id":143937,"avatar_url":"https://avatars.githubusercontent.com/u/143937?v=3","gravatar_id":"","url":"https://api.github.com/users/symfony","html_url":"https://github.com/symfony","followers_url":"https://api.github.com/users/symfony/followers","following_url":"https://api.github.com/users/symfony/following{/other_user}","gists_url":"https://api.github.com/users/symfony/gists{/gist_id}","starred_url":"https://api.github.com/users/symfony/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/symfony/subscriptions","organizations_url":"https://api.github.com/users/symfony/orgs","repos_url":"https://api.github.com/users/symfony/repos","events_url":"https://api.github.com/users/symfony/events{/privacy}","received_events_url":"https://api.github.com/users/symfony/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/symfony/symfony-docs","description":"The Symfony documentation","fork":false,"url":"https://api.github.com/repos/symfony/symfony-docs","forks_url":"https://api.github.com/repos/symfony/symfony-docs/forks","keys_url":"https://api.github.com/repos/symfony/symfony-docs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/symfony/symfony-docs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/symfony/symfony-docs/teams","hooks_url":"https://api.github.com/repos/symfony/symfony-docs/hooks","issue_events_url":"https://api.github.com/repos/symfony/symfony-docs/issues/events{/number}","events_url":"https://api.github.com/repos/symfony/symfony-docs/events","assignees_url":"https://api.github.com/repos/symfony/symfony-docs/assignees{/user}","branches_url":"https://api.github.com/repos/symfony/symfony-docs/branches{/branch}","tags_url":"https://api.github.com/repos/symfony/symfony-docs/tags","blobs_url":"https://api.github.com/repos/symfony/symfony-docs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/symfony/symfony-docs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/symfony/symfony-docs/git/refs{/sha}","trees_url":"https://api.github.com/repos/symfony/symfony-docs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/symfony/symfony-docs/statuses/{sha}","languages_url":"https://api.github.com/repos/symfony/symfony-docs/languages","stargazers_url":"https://api.github.com/repos/symfony/symfony-docs/stargazers","contributors_url":"https://api.github.com/repos/symfony/symfony-docs/contributors","subscribers_url":"https://api.github.com/repos/symfony/symfony-docs/subscribers","subscription_url":"https://api.github.com/repos/symfony/symfony-docs/subscription","commits_url":"https://api.github.com/repos/symfony/symfony-docs/commits{/sha}","git_commits_url":"https://api.github.com/repos/symfony/symfony-docs/git/commits{/sha}","comments_url":"https://api.github.com/repos/symfony/symfony-docs/comments{/number}","issue_comment_url":"https://api.github.com/repos/symfony/symfony-docs/issues/comments{/number}","contents_url":"https://api.github.com/repos/symfony/symfony-docs/contents/{+path}","compare_url":"https://api.github.com/repos/symfony/symfony-docs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/symfony/symfony-docs/merges","archive_url":"https://api.github.com/repos/symfony/symfony-docs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/symfony/symfony-docs/downloads","issues_url":"https://api.github.com/repos/symfony/symfony-docs/issues{/number}","pulls_url":"https://api.github.com/repos/symfony/symfony-docs/pulls{/number}","milestones_url":"https://api.github.com/repos/symfony/symfony-docs/milestones{/number}","notifications_url":"https://api.github.com/repos/symfony/symfony-docs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/symfony/symfony-docs/labels{/name}","releases_url":"https://api.github.com/repos/symfony/symfony-docs/releases{/id}","deployments_url":"https://api.github.com/repos/symfony/symfony-docs/deployments","created_at":"2010-02-17T08:43:51Z","updated_at":"2016-05-19T07:17:22Z","pushed_at":"2016-05-21T13:50:56Z","git_url":"git://github.com/symfony/symfony-docs.git","ssh_url":"git@github.com:symfony/symfony-docs.git","clone_url":"https://github.com/symfony/symfony-docs.git","svn_url":"https://github.com/symfony/symfony-docs","homepage":"http://symfony.com/doc","size":55217,"stargazers_count":1108,"watchers_count":1108,"language":"C++","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":2427,"mirror_url":null,"open_issues_count":314,"forks":2427,"open_issues":314,"watchers":1108,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556"},"html":{"href":"https://github.com/symfony/symfony-docs/pull/6556"},"issue":{"href":"https://api.github.com/repos/symfony/symfony-docs/issues/6556"},"comments":{"href":"https://api.github.com/repos/symfony/symfony-docs/issues/6556/comments"},"review_comments":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556/comments"},"review_comment":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/symfony/symfony-docs/pulls/6556/commits"},"statuses":{"href":"https://api.github.com/repos/symfony/symfony-docs/statuses/ecfd34d3d051a674fb1ac9d7072adf6694fbced2"}}}}
{"actor":{"display_login":"javiereguiluz"}}