commit
115c7c256e
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
namespace App\Security;
|
||||
|
||||
use App\Exception\AccountDeletedException;
|
||||
use App\Security\User as AppUser;
|
||||
use Symfony\Component\Security\Core\Exception\AccountExpiredException;
|
||||
use Symfony\Component\Security\Core\Exception\CustomUserMessageAuthenticationException;
|
||||
use Symfony\Component\Security\Core\User\UserCheckerInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
|
||||
class UserChecker implements UserCheckerInterface
|
||||
{
|
||||
public function checkPreAuth(UserInterface $user)
|
||||
{
|
||||
if (!$user instanceof AppUser) {
|
||||
return;
|
||||
}
|
||||
|
||||
// user is not activated
|
||||
if ($user-> getActive() === false) {
|
||||
throw new AccountDeletedException();
|
||||
}
|
||||
}
|
||||
|
||||
public function checkPostAuth(UserInterface $user)
|
||||
{
|
||||
if (!$user instanceof AppUser) {
|
||||
return;
|
||||
}
|
||||
|
||||
// user is not activated
|
||||
if ($user->getActive() === false) {
|
||||
throw new AccountDeletedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Entity\User;
|
||||
|
||||
Class Menus
|
||||
{
|
||||
public function getMenus(User $user)
|
||||
{
|
||||
|
||||
|
||||
$menus = array(
|
||||
array(
|
||||
"route" => "app_logout",
|
||||
"title" => "log out"
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
if( $user->isGranted('SUPER_ADMIN') )
|
||||
{
|
||||
$menus[] = array(
|
||||
"route" => "users",
|
||||
"title" => "Users"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $menus;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
{% extends 'base.html.twig' %}
|
||||
|
||||
{% block header %}<h1>Gestionnaire de ressources</h1>{% endblock %}
|
||||
|
||||
{% block title %}Page d'accueil{% endblock %}
|
||||
{% block nav %}{% include 'menus.html.twig' %}{% endblock %}
|
||||
|
||||
{% block content %}Hey hey!{% endblock %}
|
@ -0,0 +1,7 @@
|
||||
<ul>
|
||||
{% for m in menus %}
|
||||
<li>
|
||||
<a href="{{ path(m.route) }}">{{ m.title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
Loading…
Reference in New Issue