for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Core\Modules;
use \Core\Container;
/**
* Authentication class taking care of access rights
* Class Auth
* @package Core\Modules
*/
class Auth extends Module
{
//TODO session_level isn't explicit enough. Have to change things up a bit. Probably use user_role_name and user_role_level
* get the user type
* @return mixed
public function getUser()
$session = $this->container->getSession();
return $session->get('session_level');
}
* Gets the user level defined in the session (this is set on login and also stored in the DB).
* Returns an int for easier user control.
* @return int
public function getUserLevel()
//For testing, setting the user level
//$session->set('session_level', 'Admin');
//get session level from the actual $_SESSION
$sessionLevel = $session->get('session_level');
//we could use a binary system for the rights but not much granular levels to take care of
if ($sessionLevel) {
if ($sessionLevel === 'Admin') {
return 2;
if ($sessionLevel === 'User') {
return 1;
return 0;
* is the connected user an Admin
* @return bool
public function isAdmin()
$userLevel = $this->getUserLevel();
if ($userLevel > 1) {
return true;
return false;
* is the user connected ?
public function isUser()
if ($userLevel > 0) {