for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Linna Framework.
*
* @author Sebastian Rapetti <[email protected]>
* @copyright (c) 2017, Sebastian Rapetti
* @license http://opensource.org/licenses/MIT MIT License
*/
declare(strict_types=1);
namespace Linna\Authentication;
* Help protect a controller with login.
trait ProtectedController
{
* @var bool Contain login status
protected $authentication = false;
* Allow access to controller only if logged.
* @param Authenticate $authenticate
* @param string $redirect
protected function protect(Authenticate $authenticate, string $redirect)
if (($this->authentication = $authenticate->isLogged()) === false) {
header('Location: '.$redirect);
}