mirror of
https://github.com/resources-manager/resources-manager-webui.git
synced 2024-11-21 23:49:19 +01:00
commit
115c7c256e
|
@ -14,8 +14,11 @@ security:
|
||||||
dev:
|
dev:
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
security: false
|
security: false
|
||||||
|
|
||||||
main:
|
main:
|
||||||
anonymous: ~
|
anonymous: ~
|
||||||
|
pattern: ^/
|
||||||
|
user_checker: App\Security\UserChecker
|
||||||
guard:
|
guard:
|
||||||
authenticators:
|
authenticators:
|
||||||
- App\Security\LoginFormAuthentificatorAuthenticator
|
- App\Security\LoginFormAuthentificatorAuthenticator
|
||||||
|
|
|
@ -17,3 +17,8 @@ register:
|
||||||
path: /register
|
path: /register
|
||||||
controller: App\Controller\SecurityController::register
|
controller: App\Controller\SecurityController::register
|
||||||
methods: POST
|
methods: POST
|
||||||
|
|
||||||
|
users:
|
||||||
|
path: /users
|
||||||
|
controller: App\Controller\SecurityController::showUserManagePage
|
||||||
|
methods: GET
|
|
@ -5,7 +5,7 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
|
use App\Service\Menus;
|
||||||
|
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
@ -14,9 +14,11 @@ Class HomeController extends AbstractController
|
||||||
{
|
{
|
||||||
public function index(){
|
public function index(){
|
||||||
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
$this->denyAccessUnlessGranted('IS_AUTHENTICATED_FULLY');
|
||||||
return new Response(
|
|
||||||
"Hey"
|
$menus = new Menus();
|
||||||
);
|
return $this->render('main.html.twig', [
|
||||||
|
"menus" => $menus->getMenus( $this->getUser() )
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -68,7 +68,6 @@ class SecurityController extends AbstractController
|
||||||
{
|
{
|
||||||
$form = $this->getRegisterForm();
|
$form = $this->getRegisterForm();
|
||||||
$form->handleRequest($request);
|
$form->handleRequest($request);
|
||||||
echo "hey";
|
|
||||||
if ($form->isSubmitted() && $form->isValid())
|
if ($form->isSubmitted() && $form->isValid())
|
||||||
{
|
{
|
||||||
$data = $form->getData();
|
$data = $form->getData();
|
||||||
|
@ -94,4 +93,9 @@ class SecurityController extends AbstractController
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function showUserManagePage()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,6 +70,11 @@ class User implements UserInterface
|
||||||
return (string) $this->email;
|
return (string) $this->email;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isGranted($role): bool
|
||||||
|
{
|
||||||
|
return in_array($role, $this->getRoles());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see UserInterface
|
* @see UserInterface
|
||||||
*/
|
*/
|
||||||
|
|
36
src/Security/UserChecker.php
Normal file
36
src/Security/UserChecker.php
Normal file
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
34
src/Service/Menus.php
Normal file
34
src/Service/Menus.php
Normal file
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -10,10 +10,10 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>{% block header %}<h1>Resources booking manager</h1>{% endblock %}</header>
|
<header>{% block header %}<h1>Resources booking manager</h1>{% endblock %}</header>
|
||||||
<nav></nav>
|
<nav>{% block nav %}{% endblock %}</nav>
|
||||||
{% block overcontent %}
|
{% block overcontent %}
|
||||||
<section id="main">
|
<section id="main">
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% include 'menu.html.twig' %}{% endblock %}
|
||||||
</section>
|
</section>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<footer></footer>
|
<footer></footer>
|
||||||
|
|
8
templates/main.html.twig
Normal file
8
templates/main.html.twig
Normal file
|
@ -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 %}
|
7
templates/menus.html.twig
Normal file
7
templates/menus.html.twig
Normal file
|
@ -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
Block a user