Files
lichterei-web/kirby/config/api/authentication.php
Bastian Allgeier a431716732 Upgrade to 3.3.0
2019-11-05 09:35:58 +01:00

24 lines
583 B
PHP
Executable File

<?php
use Kirby\Exception\PermissionException;
return function () {
$auth = $this->kirby()->auth();
// csrf token check
if ($auth->type() === 'session' && $auth->csrf() === false) {
throw new PermissionException('Unauthenticated');
}
// get user from session or basic auth
if ($user = $auth->user()) {
if ($user->role()->permissions()->for('access', 'panel') === false) {
throw new PermissionException(['key' => 'access.panel']);
}
return $user;
}
throw new PermissionException('Unauthenticated');
};