{"action":"opened","issue":{"url":"https://api.github.com/repos/cakephp/cakephp/issues/9040","repository_url":"https://api.github.com/repos/cakephp/cakephp","labels_url":"https://api.github.com/repos/cakephp/cakephp/issues/9040/labels{/name}","comments_url":"https://api.github.com/repos/cakephp/cakephp/issues/9040/comments","events_url":"https://api.github.com/repos/cakephp/cakephp/issues/9040/events","html_url":"https://github.com/cakephp/cakephp/issues/9040","id":162462204,"number":9040,"title":"Auth component redirects to last JSON ajax requested page","user":{"login":"gestudio","id":1157693,"avatar_url":"https://avatars.githubusercontent.com/u/1157693?v=3","gravatar_id":"","url":"https://api.github.com/users/gestudio","html_url":"https://github.com/gestudio","followers_url":"https://api.github.com/users/gestudio/followers","following_url":"https://api.github.com/users/gestudio/following{/other_user}","gists_url":"https://api.github.com/users/gestudio/gists{/gist_id}","starred_url":"https://api.github.com/users/gestudio/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gestudio/subscriptions","organizations_url":"https://api.github.com/users/gestudio/orgs","repos_url":"https://api.github.com/users/gestudio/repos","events_url":"https://api.github.com/users/gestudio/events{/privacy}","received_events_url":"https://api.github.com/users/gestudio/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-06-27T14:14:35Z","updated_at":"2016-06-27T14:14:35Z","closed_at":null,"body":"This is a (multiple allowed):\r\n* [x] bug\r\n* [ ] enhancement\r\n* [ ] feature-discussion (RFC)\r\n\r\n* CakePHP Version: 2.8.4\r\n* Platform and Target: Centos 7, nginx..\r\n\r\n### What you did\r\nAngularJs $http ajax request.\r\n\r\n### Expected Behavior\r\nJson ajax requests should not be stored in Session Auth.redirect value.\r\n\r\n### Actual Behavior\r\nAuth component is storing JSON ajax requests in Auth.redirect session value causing login redirects to JSON response pages. \r\nRequestHandler will not recognize the JSON request as AJAX if the **X-Requested-With:XMLHttpRequest** header is not sent. \r\nThe AuthComponent::_unauthenticated() function should include  **or $controller->request->is('json')** in addition to the **$controller->request->is('ajax')** check.\r\n\r\n**Proposed change. Switch Line 362 AuthComponent to:**\r\n`if (!$controller->request->is('ajax') or $controller->request->is('json')) {`"}}
{"actor":{"display_login":"gestudio"}}