RestApi: allow to override permission check
This commit is contained in:
parent
e562d00a50
commit
475c84de1e
|
@ -18,13 +18,17 @@ trait RestApi
|
|||
}
|
||||
}
|
||||
|
||||
protected function assertApiPermission()
|
||||
{
|
||||
if (! $this->hasPermission('director/api')) {
|
||||
throw new AuthenticationException('You are not allowed to access this API');
|
||||
}
|
||||
}
|
||||
|
||||
protected function checkForRestApiRequest()
|
||||
{
|
||||
if ($this->getRequest()->isApiRequest()) {
|
||||
if (! $this->hasPermission('director/api')) {
|
||||
throw new AuthenticationException('You are not allowed to access this API');
|
||||
}
|
||||
|
||||
$this->assertApiPermission();
|
||||
if (! $this->isApified()) {
|
||||
throw new NotFoundError('No such API endpoint found');
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue