mirror of
https://github.com/flextype/flextype.git
synced 2025-08-24 13:52:56 +02:00
- Flextype Admin Panel: general code cleanup and refactoring #182
This commit is contained in:
@@ -1,12 +1,37 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Flextype
|
||||
*
|
||||
* @author Sergey Romanenko <hello@romanenko.digital>
|
||||
* @link http://romanenko.digital
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Flextype\Component\Session\Session;
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
/**
|
||||
* @property Router $router
|
||||
*/
|
||||
class AuthMiddleware extends Middleware
|
||||
{
|
||||
public function __invoke($request, $response, $next)
|
||||
|
||||
/**
|
||||
* __invoke
|
||||
*
|
||||
* @param Request $request PSR7 request
|
||||
* @param Response $response PSR7 response
|
||||
* @param callable $next Next middleware
|
||||
*
|
||||
* @return Response
|
||||
*/
|
||||
public function __invoke(Request $request, Response $response, $next) : Response
|
||||
{
|
||||
if (Session::exists('role') && Session::get('role') == 'admin') {
|
||||
$response = $next($request, $response);
|
||||
|
@@ -29,6 +29,9 @@ class GlobalVarsAdminTwigExtension extends \Twig_Extension implements \Twig_Exte
|
||||
$this->flextype = $flextype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register Global variables in an extension
|
||||
*/
|
||||
public function getGlobals()
|
||||
{
|
||||
return [
|
||||
|
Reference in New Issue
Block a user