1
0
This repository has been archived on 2017-06-06. You can view files and clone it, but cannot push or open issues or pull requests.
informaticaD4P-2017/src/Application/Auth/Middleware.php

35 lines
736 B
PHP

<?php
/**
* Informatica Eindproject D4p
* 6in3, Stedelijk Gymnasium Nijmegen
* Docent: Hans de Wolf
*
* ==================
*
* Daniel Boutros,
* Christiaan Goossens,
* Jelmer Hinssen
*/
namespace Inforbank\Application\Auth;
use Inforbank\Application;
use Inforbank\Application\Helper\Redirect;
class Middleware
{
public function __invoke($request, $response, $next)
{
$container = Application::getContainer();
// Check for an existing session
if ($container->auth->isUserAuthenticated()) {
return $next($request, $response);
} else {
// Redirect to the login page
return Redirect::create($request, $response, '/login');
}
}
}