mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #1756 from halkyon/permission_denied_hook
BUG Security::permissionFailure() fixing permissionDenied hook inconsistency
This commit is contained in:
commit
15f7c884f8
@ -222,17 +222,20 @@ class Security extends Controller {
|
|||||||
$messageSet = array('default' => $messageSet);
|
$messageSet = array('default' => $messageSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$member = Member::currentUser();
|
||||||
|
|
||||||
// Work out the right message to show
|
// Work out the right message to show
|
||||||
if(Member::currentUser()) {
|
if($member && $member->exists()) {
|
||||||
$response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse();
|
$response = ($controller) ? $controller->getResponse() : new SS_HTTPResponse();
|
||||||
$response->setStatusCode(403);
|
$response->setStatusCode(403);
|
||||||
|
|
||||||
//If 'alreadyLoggedIn' is not specified in the array, then use the default
|
//If 'alreadyLoggedIn' is not specified in the array, then use the default
|
||||||
//which should have been specified in the lines above
|
//which should have been specified in the lines above
|
||||||
if(isset($messageSet['alreadyLoggedIn']))
|
if(isset($messageSet['alreadyLoggedIn'])) {
|
||||||
$message = $messageSet['alreadyLoggedIn'];
|
$message = $messageSet['alreadyLoggedIn'];
|
||||||
else
|
} else {
|
||||||
$message = $messageSet['default'];
|
$message = $messageSet['default'];
|
||||||
|
}
|
||||||
|
|
||||||
// Somewhat hackish way to render a login form with an error message.
|
// Somewhat hackish way to render a login form with an error message.
|
||||||
$me = new Security();
|
$me = new Security();
|
||||||
@ -242,6 +245,9 @@ class Security extends Controller {
|
|||||||
$formText = $me->login();
|
$formText = $me->login();
|
||||||
|
|
||||||
$response->setBody($formText);
|
$response->setBody($formText);
|
||||||
|
|
||||||
|
$controller->extend('permissionDenied', $member);
|
||||||
|
|
||||||
return $response;
|
return $response;
|
||||||
} else {
|
} else {
|
||||||
$message = $messageSet['default'];
|
$message = $messageSet['default'];
|
||||||
|
Loading…
Reference in New Issue
Block a user