{"action":"created","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5414","repository_url":"https://api.github.com/repos/silverstripe/silverstripe-framework","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5414/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5414/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5414/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5414","id":151737982,"number":5414,"title":"Redirect in permissionDenied gives Already directed to error","user":{"login":"axyr","id":345155,"avatar_url":"https://avatars.githubusercontent.com/u/345155?v=3","gravatar_id":"","url":"https://api.github.com/users/axyr","html_url":"https://github.com/axyr","followers_url":"https://api.github.com/users/axyr/followers","following_url":"https://api.github.com/users/axyr/following{/other_user}","gists_url":"https://api.github.com/users/axyr/gists{/gist_id}","starred_url":"https://api.github.com/users/axyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axyr/subscriptions","organizations_url":"https://api.github.com/users/axyr/orgs","repos_url":"https://api.github.com/users/axyr/repos","events_url":"https://api.github.com/users/axyr/events{/privacy}","received_events_url":"https://api.github.com/users/axyr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-28T20:39:57Z","updated_at":"2016-05-20T09:53:29Z","closed_at":null,"body":"Adding this method to a Page_Controller extension to prevent the redirect to Security/login : \r\n\r\n```php\r\npublic function permissionDenied(Member $member = null)\r\n{\r\n    if($page = LoginPage::get()->first()) {\r\n        return $this->owner->redirect($page->Link());\r\n    }\r\n}\r\n```\r\n\r\nWe can use Config::inst()->update('Security', 'login_url', '/myCustomLoginFormURL'); but this does not works when using Translatable or when we want to use a PageType for it.\r\n\r\nIf we check for a return in \r\n\r\n```php\r\n$controller->extend('permissionDenied', $member);\r\n```\r\n , we could prevent this, but i'm not sure if this is the way to go : \r\n\r\n```php\r\n// Security::permissionFailure();\r\n$response->setBody($formText);\r\n\r\n$result = $controller->extend('permissionDenied', $member);\r\n\r\nreturn $result ? $result : $response;\r\n\r\n// ....\r\n\r\n// Audit logging hook\r\n$result = $controller->extend('permissionDenied', $member);\r\n\r\nreturn $result ? $result : $controller->redirect(\r\n\tConfig::inst()->get('Security', 'login_url')\r\n\t. \"?BackURL=\" . urlencode($_SERVER['REQUEST_URI'])\r\n);\r\n\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/comments/220564464","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5414#issuecomment-220564464","issue_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5414","id":220564464,"user":{"login":"axyr","id":345155,"avatar_url":"https://avatars.githubusercontent.com/u/345155?v=3","gravatar_id":"","url":"https://api.github.com/users/axyr","html_url":"https://github.com/axyr","followers_url":"https://api.github.com/users/axyr/followers","following_url":"https://api.github.com/users/axyr/following{/other_user}","gists_url":"https://api.github.com/users/axyr/gists{/gist_id}","starred_url":"https://api.github.com/users/axyr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/axyr/subscriptions","organizations_url":"https://api.github.com/users/axyr/orgs","repos_url":"https://api.github.com/users/axyr/repos","events_url":"https://api.github.com/users/axyr/events{/privacy}","received_events_url":"https://api.github.com/users/axyr/received_events","type":"User","site_admin":false},"created_at":"2016-05-20T09:53:29Z","updated_at":"2016-05-20T09:53:29Z","body":"I figure this out with a clean install this weekend.\r\n\r\nThanks for your replies!"}}
{"actor":{"display_login":"axyr"}}