API CHANGE: Add a PermissionFailureException that can be thrown to trigger a log-in.

This commit is contained in:
Sam Minnee 2011-03-16 15:45:43 +13:00 committed by Ingo Schommer
parent 6cb1570282
commit f54697930e
2 changed files with 12 additions and 0 deletions

View File

@ -184,6 +184,8 @@ class RequestHandler extends ViewableData {
$result = $this->$action($request);
} catch(SS_HTTPResponse_Exception $responseException) {
$result = $responseException->getResponse();
} catch(PermissionFailureException $e) {
$result = Security::permissionFailure(null, $e->getMessage());
}
} else {
return $this->httpError(403, "Action '$action' isn't allowed on class " . get_class($this));

View 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 {
}