mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE: Add a PermissionFailureException that can be thrown to trigger a log-in.
This commit is contained in:
parent
6cb1570282
commit
f54697930e
@ -184,6 +184,8 @@ class RequestHandler extends ViewableData {
|
|||||||
$result = $this->$action($request);
|
$result = $this->$action($request);
|
||||||
} catch(SS_HTTPResponse_Exception $responseException) {
|
} catch(SS_HTTPResponse_Exception $responseException) {
|
||||||
$result = $responseException->getResponse();
|
$result = $responseException->getResponse();
|
||||||
|
} catch(PermissionFailureException $e) {
|
||||||
|
$result = Security::permissionFailure(null, $e->getMessage());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this));
|
return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this));
|
||||||
|
10
security/PermissionFailureException.php
Normal file
10
security/PermissionFailureException.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throw this exception to register that a user doesn't have permission to do the given action
|
||||||
|
* and potentially redirect them to the log-in page. The exception message may be presented to the
|
||||||
|
* user, so it shouldn't be in nerd-speak.
|
||||||
|
*/
|
||||||
|
class PermissionFailureException extends Exception {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user