1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 19:30:40 +02:00

Version 1.3.8: ACL-Implementation

This commit is contained in:
trendschau
2020-07-04 08:06:18 +02:00
parent 2965a068d8
commit 74ecf7457e
28 changed files with 537 additions and 154 deletions

View File

@@ -0,0 +1,37 @@
<?php
namespace Typemill\Middleware;
use Slim\Interfaces\RouterInterface;
use Slim\Http\Request;
use Slim\Http\Response;
class accessController
{
protected $router;
public function __construct(RouterInterface $router, $acl, $resource, $privilege)
{
$this->router = $router;
$this->acl = $acl;
$this->resource = $resource;
$this->privilege = $privilege;
}
public function __invoke(Request $request, Response $response, $next)
{
if(!isset($_SESSION['login']))
{
return $response->withRedirect($this->router->pathFor('auth.show'));
}
if(!$this->acl->isAllowed($_SESSION['role'], $this->resource, $this->privilege ))
{
# redirect to frontend startpage
# alternatively return an error and show an error page.
return $response->withRedirect($this->router->pathFor('home'));
}
return $next($request, $response);
}
}