Passed
Push — master ( 83de64...44197b )
by Anthony
02:43
created
Controller/UserLogsController.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -10,45 +10,45 @@
 block discarded – undo
10 10
 
11 11
 class UserLogsController extends AbstractController
12 12
 {
13
-    /**
14
-     * list all user logs
15
-     * @Route("/user-logs/{page}", requirements={"page" = "\d+"}, name="ribsadmin_userlogs")
16
-     * @param ParameterBagInterface $parameterBag
17
-     * @param int $page
18
-     * @return Response
19
-     */
20
-    public function list(ParameterBagInterface $parameterBag, int $page = 1): Response
21
-    {
22
-        $em = $this->getDoctrine()->getManager();
23
-        $max_per_page = $parameterBag->get("ribs_admin")["paginator_element_per_page"];
13
+				/**
14
+				 * list all user logs
15
+				 * @Route("/user-logs/{page}", requirements={"page" = "\d+"}, name="ribsadmin_userlogs")
16
+				 * @param ParameterBagInterface $parameterBag
17
+				 * @param int $page
18
+				 * @return Response
19
+				 */
20
+				public function list(ParameterBagInterface $parameterBag, int $page = 1): Response
21
+				{
22
+								$em = $this->getDoctrine()->getManager();
23
+								$max_per_page = $parameterBag->get("ribs_admin")["paginator_element_per_page"];
24 24
 
25
-        $logs = $em->getRepository(UserLogs::class)->findAllPaginated($page, $max_per_page);
26
-        $pagination = array(
27
-            "page" => $page,
28
-            "page_number" => ceil(count($logs) / 20),
29
-            "route" => "ribsadmin_userlogs",
30
-            "parameters" => array()
31
-        );
25
+								$logs = $em->getRepository(UserLogs::class)->findAllPaginated($page, $max_per_page);
26
+								$pagination = array(
27
+												"page" => $page,
28
+												"page_number" => ceil(count($logs) / 20),
29
+												"route" => "ribsadmin_userlogs",
30
+												"parameters" => array()
31
+								);
32 32
 
33
-        return $this->render("@RibsAdmin/userlogs/list.html.twig", [
34
-            "logs" => $logs,
35
-            "pagination" => $pagination
36
-        ]);
37
-    }
33
+								return $this->render("@RibsAdmin/userlogs/list.html.twig", [
34
+												"logs" => $logs,
35
+												"pagination" => $pagination
36
+								]);
37
+				}
38 38
 
39
-    /**
40
-     * show detail of a user log
41
-     * @Route("/user-logs/show/{guid}", name="ribsadmin_userlogs_show")
42
-     * @param string $guid
43
-     * @return Response
44
-     */
45
-    public function show(string $guid): Response
46
-    {
47
-        $log = $this->getDoctrine()->getRepository(UserLogs::class)->findOneByGuid($guid);
48
-        dump($log->getRequestParameters());
39
+				/**
40
+				 * show detail of a user log
41
+				 * @Route("/user-logs/show/{guid}", name="ribsadmin_userlogs_show")
42
+				 * @param string $guid
43
+				 * @return Response
44
+				 */
45
+				public function show(string $guid): Response
46
+				{
47
+								$log = $this->getDoctrine()->getRepository(UserLogs::class)->findOneByGuid($guid);
48
+								dump($log->getRequestParameters());
49 49
 
50
-        return $this->render("@RibsAdmin/userlogs/show.html.twig", [
51
-            "log" => $log,
52
-        ]);
53
-    }
50
+								return $this->render("@RibsAdmin/userlogs/show.html.twig", [
51
+												"log" => $log,
52
+								]);
53
+				}
54 54
 }
Please login to merge, or discard this patch.
Service/UserLog.php 1 patch
Indentation   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -9,48 +9,48 @@
 block discarded – undo
9 9
 
10 10
 class UserLog
11 11
 {
12
-    /**
13
-     * @var TokenStorageInterface
14
-     */
15
-    private $token_storage;
16
-
17
-    /**
18
-     * @var EntityManagerInterface a
19
-     */
20
-    private $em;
21
-
22
-    public function __construct(TokenStorageInterface $token_storage, EntityManagerInterface $em)
23
-    {
24
-        $this->token_storage = $token_storage;
25
-        $this->em = $em;
26
-    }
27
-
28
-    /**
29
-     * @param RequestEvent $request_event
30
-     */
31
-    public function onKernelRequest(RequestEvent $request_event)
32
-    {
33
-        if ($request_event->isMasterRequest()) {
34
-            $user = null;
35
-            if ($this->token_storage->getToken() && is_object($this->token_storage->getToken()->getUser()) && $this->token_storage->getToken()->getUser()->getUser()) {
36
-                $user = $this->token_storage->getToken()->getUser()->getUser();
37
-            }
38
-            $request = $request_event->getRequest();
39
-            $route = $request->get("_route");
40
-
41
-            if (in_array($route, ["_profiler", "_profiler_search_bar", "_wdt", "ribsadmin_userlogs", "ribsadmin_userlogs_show"])) {
42
-                return;
43
-            }
44
-
45
-            if ($user) {
46
-                $user_log = new UserLogs();
47
-                $user_log->setMethod($request->getMethod());
48
-                $user_log->setUser($user);
49
-                $user_log->setUrl($request->get("_route"));
50
-                $user_log->setRequestParameters($request->request->all());
51
-                $this->em->persist($user_log);
52
-                $this->em->flush();
53
-            }
54
-        }
55
-    }
12
+				/**
13
+				 * @var TokenStorageInterface
14
+				 */
15
+				private $token_storage;
16
+
17
+				/**
18
+				 * @var EntityManagerInterface a
19
+				 */
20
+				private $em;
21
+
22
+				public function __construct(TokenStorageInterface $token_storage, EntityManagerInterface $em)
23
+				{
24
+								$this->token_storage = $token_storage;
25
+								$this->em = $em;
26
+				}
27
+
28
+				/**
29
+				 * @param RequestEvent $request_event
30
+				 */
31
+				public function onKernelRequest(RequestEvent $request_event)
32
+				{
33
+								if ($request_event->isMasterRequest()) {
34
+												$user = null;
35
+												if ($this->token_storage->getToken() && is_object($this->token_storage->getToken()->getUser()) && $this->token_storage->getToken()->getUser()->getUser()) {
36
+																$user = $this->token_storage->getToken()->getUser()->getUser();
37
+												}
38
+												$request = $request_event->getRequest();
39
+												$route = $request->get("_route");
40
+
41
+												if (in_array($route, ["_profiler", "_profiler_search_bar", "_wdt", "ribsadmin_userlogs", "ribsadmin_userlogs_show"])) {
42
+																return;
43
+												}
44
+
45
+												if ($user) {
46
+																$user_log = new UserLogs();
47
+																$user_log->setMethod($request->getMethod());
48
+																$user_log->setUser($user);
49
+																$user_log->setUrl($request->get("_route"));
50
+																$user_log->setRequestParameters($request->request->all());
51
+																$this->em->persist($user_log);
52
+																$this->em->flush();
53
+												}
54
+								}
55
+				}
56 56
 }
Please login to merge, or discard this patch.
DependencyInjection/RibsAdminExtension.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -9,12 +9,12 @@
 block discarded – undo
9 9
 
10 10
 class RibsAdminExtension extends Extension
11 11
 {
12
-    public function load(array $configs, ContainerBuilder $container)
13
-    {
14
-        $loader = new YamlFileLoader(
15
-            $container,
16
-            new FileLocator(__DIR__ . '/../Resources/config')
17
-        );
18
-        $loader->load('services.yml');
19
-    }
12
+				public function load(array $configs, ContainerBuilder $container)
13
+				{
14
+								$loader = new YamlFileLoader(
15
+												$container,
16
+												new FileLocator(__DIR__ . '/../Resources/config')
17
+								);
18
+								$loader->load('services.yml');
19
+				}
20 20
 }
Please login to merge, or discard this patch.
EventListener/CreateUpdateAwareListener.php 1 patch
Indentation   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -7,43 +7,43 @@
 block discarded – undo
7 7
 
8 8
 class CreateUpdateAwareListener
9 9
 {
10
-    /**
11
-     * @var User
12
-     */
13
-    private $user;
10
+				/**
11
+				 * @var User
12
+				 */
13
+				private $user;
14 14
 
15
-    /**
16
-     * CreateUpdateAwareListener constructor.
17
-     * @param TokenStorage $tokenStorage
18
-     */
19
-    public function __construct(TokenStorage $tokenStorage)
20
-    {
21
-        if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) {
22
-            $this->user = $tokenStorage->getToken()->getUser()->getUser();
23
-        } else {
24
-            $this->user = null;
25
-        }
26
-    }
15
+				/**
16
+				 * CreateUpdateAwareListener constructor.
17
+				 * @param TokenStorage $tokenStorage
18
+				 */
19
+				public function __construct(TokenStorage $tokenStorage)
20
+				{
21
+								if ($tokenStorage->getToken() && is_object($tokenStorage->getToken()->getUser()) && $tokenStorage->getToken()->getUser()->getUser()) {
22
+												$this->user = $tokenStorage->getToken()->getUser()->getUser();
23
+								} else {
24
+												$this->user = null;
25
+								}
26
+				}
27 27
 
28
-    public function prePersist($entity)
29
-    {
30
-        if ($this->user) {
31
-            if ($entity->getCreatedBy() === null) {
32
-                $entity->setCreatedAt(new \DateTime());
33
-                $entity->setCreatedBy($this->user);
34
-            }
35
-            if ($entity->getUpdatedBy() === null) {
36
-                $entity->setUpdatedAt(new \DateTime());
37
-                $entity->setUpdatedBy($this->user);
38
-            }
39
-        }
40
-    }
28
+				public function prePersist($entity)
29
+				{
30
+								if ($this->user) {
31
+												if ($entity->getCreatedBy() === null) {
32
+																$entity->setCreatedAt(new \DateTime());
33
+																$entity->setCreatedBy($this->user);
34
+												}
35
+												if ($entity->getUpdatedBy() === null) {
36
+																$entity->setUpdatedAt(new \DateTime());
37
+																$entity->setUpdatedBy($this->user);
38
+												}
39
+								}
40
+				}
41 41
 
42
-    public function preUpdate($entity)
43
-    {
44
-        if ($this->user) {
45
-            $entity->setUpdatedAt(new \DateTime());
46
-            $entity->setUpdatedBy($this->user);
47
-        }
48
-    }
42
+				public function preUpdate($entity)
43
+				{
44
+								if ($this->user) {
45
+												$entity->setUpdatedAt(new \DateTime());
46
+												$entity->setUpdatedBy($this->user);
47
+								}
48
+				}
49 49
 }
Please login to merge, or discard this patch.
EventListener/GuidAwareListener.php 2 patches
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -7,24 +7,24 @@
 block discarded – undo
7 7
 
8 8
 class GuidAwareListener
9 9
 {
10
-    /**
11
-     * @var ContainerInterface
12
-     */
13
-    private $container;
10
+				/**
11
+				 * @var ContainerInterface
12
+				 */
13
+				private $container;
14 14
 
15
-    /**
16
-     * GuidAwareListener constructor.
17
-     * @param ContainerInterface $container
18
-     */
19
-    public function __construct(ContainerInterface $container)
20
-    {
21
-        $this->container = $container;
22
-    }
15
+				/**
16
+				 * GuidAwareListener constructor.
17
+				 * @param ContainerInterface $container
18
+				 */
19
+				public function __construct(ContainerInterface $container)
20
+				{
21
+								$this->container = $container;
22
+				}
23 23
 
24
-    public function prePersist($entity)
25
-    {
26
-        if ($entity->getGuid() === null) {
27
-            $entity->setGuid((string)Uuid::uuid4());
28
-        }
29
-    }
24
+				public function prePersist($entity)
25
+				{
26
+								if ($entity->getGuid() === null) {
27
+												$entity->setGuid((string)Uuid::uuid4());
28
+								}
29
+				}
30 30
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
     public function prePersist($entity)
25 25
     {
26 26
         if ($entity->getGuid() === null) {
27
-            $entity->setGuid((string)Uuid::uuid4());
27
+            $entity->setGuid((string) Uuid::uuid4());
28 28
         }
29 29
     }
30 30
 }
Please login to merge, or discard this patch.
Controller/LoginController.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -10,44 +10,44 @@
 block discarded – undo
10 10
 
11 11
 class LoginController extends AbstractController
12 12
 {
13
-    /**
14
-     * @Route("/login/", name="ribsadmin_login")
15
-     * @param AuthenticationUtils $auth_utils
16
-     * @return Response
17
-     */
18
-    public function loginAction(AuthenticationUtils $auth_utils): Response
19
-    {
20
-        $csrf_token = $this->has('security.csrf.token_manager')
21
-            ? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue()
22
-            : null;
23
-
24
-        if ($auth_utils->getLastAuthenticationError()) {
25
-            $this->addFlash("error-flash", "Your login or password are incorrect");
26
-        }
27
-
28
-        // last username entered by the user
29
-        $last_username = $auth_utils->getLastUsername();
30
-
31
-        return $this->render('@RibsAdmin/login/login.html.twig', array(
32
-            'last_username' => $last_username,
33
-            'csrf_token' => $csrf_token,
34
-        ));
35
-    }
36
-
37
-    /**
38
-     * @param array $data
39
-     * @return Response
40
-     */
41
-    protected function renderLogin(array $data): Response
42
-    {
43
-        $securityContext = $this->get('security.authorization_checker');
44
-
45
-        if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
46
-            $this->addFlash("info-flash", "You were connected with success");
47
-
48
-            return new RedirectResponse($this->generateUrl("ribsadmin_index"), 303);
49
-        }
50
-
51
-        return $this->render("@RibsAdmin/login/login.html.twig", $data);
52
-    }
13
+				/**
14
+				 * @Route("/login/", name="ribsadmin_login")
15
+				 * @param AuthenticationUtils $auth_utils
16
+				 * @return Response
17
+				 */
18
+				public function loginAction(AuthenticationUtils $auth_utils): Response
19
+				{
20
+								$csrf_token = $this->has('security.csrf.token_manager')
21
+												? $this->get('security.csrf.token_manager')->getToken('authenticate')->getValue()
22
+												: null;
23
+
24
+								if ($auth_utils->getLastAuthenticationError()) {
25
+												$this->addFlash("error-flash", "Your login or password are incorrect");
26
+								}
27
+
28
+								// last username entered by the user
29
+								$last_username = $auth_utils->getLastUsername();
30
+
31
+								return $this->render('@RibsAdmin/login/login.html.twig', array(
32
+												'last_username' => $last_username,
33
+												'csrf_token' => $csrf_token,
34
+								));
35
+				}
36
+
37
+				/**
38
+				 * @param array $data
39
+				 * @return Response
40
+				 */
41
+				protected function renderLogin(array $data): Response
42
+				{
43
+								$securityContext = $this->get('security.authorization_checker');
44
+
45
+								if ($securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED') || $securityContext->isGranted('IS_AUTHENTICATED_FULLY')) {
46
+												$this->addFlash("info-flash", "You were connected with success");
47
+
48
+												return new RedirectResponse($this->generateUrl("ribsadmin_index"), 303);
49
+								}
50
+
51
+								return $this->render("@RibsAdmin/login/login.html.twig", $data);
52
+				}
53 53
 }
Please login to merge, or discard this patch.
Controller/AccessRightsController.php 1 patch
Indentation   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -13,117 +13,117 @@
 block discarded – undo
13 13
 
14 14
 class AccessRightsController extends AbstractController
15 15
 {
16
-    /**
17
-     * @Route("/access-rights-management/", name="ribsadmin_access_rights")
18
-     * @return Response
19
-     */
20
-    public function list(): Response
21
-    {
22
-        $em = $this->getDoctrine()->getManager();
23
-        $acces_right = $em->getRepository("RibsAdminBundle:AccessRight")->findAll();
24
-
25
-        return $this->render("@RibsAdmin/access-rights/list.html.twig", [
26
-            "access_right" => $acces_right
27
-        ]);
28
-    }
29
-
30
-    /**
31
-     * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create")
32
-     * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit")
33
-     * @param Request $request
34
-     * @param Globals $globals
35
-     * @param ModuleService $module
36
-     * @param string|null $guid
37
-     * @return Response
38
-     */
39
-    public function edit(Request $request, Globals $globals, ModuleService $module, string $guid = null): Response
40
-    {
41
-        $em = $this->getDoctrine()->getManager();
42
-        $list_rights_user = [];
43
-
44
-        if ($guid === null) {
45
-            $access_right = new AccessRight();
46
-        } else {
47
-            $access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]);
48
-            $list_rights_user = explode(",", $access_right->getAccessRights());
49
-        }
50
-
51
-        $admins = $em->getRepository("RibsAdminBundle:User")->findBy(["admin" => true, "archived" => false]);
52
-
53
-        $form = $this->createForm("PiouPiou\RibsAdminBundle\Form\AccessRight", $access_right);
54
-        $form->handleRequest($request);
55
-
56
-        if ($form->isSubmitted() && $form->isValid()) {
57
-            return $this->handleEditForm($request, $access_right);
58
-        }
59
-
60
-        return $this->render("@RibsAdmin/access-rights/edit.html.twig", [
61
-            "access_right" => $access_right,
62
-            "form" => $form->createView(),
63
-            "form_errors" => $form->getErrors(),
64
-            "list_rights_user" => $list_rights_user,
65
-            "admins" => $admins,
66
-            "ribs_admin_rights" => json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json")),
67
-            "modules" => $module->getAllInfosModules()
68
-        ]);
69
-    }
70
-
71
-    /**
72
-     * @Route("/access-rights-management/delete/{guid}", name="ribsadmin_access_rights_delete")
73
-     * @param string $guid
74
-     * @return RedirectResponse function that delete an access right list
75
-     */
76
-    public function delete(string $guid): RedirectResponse
77
-    {
78
-        $em = $this->getDoctrine()->getManager();
79
-        $list = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]);
80
-
81
-        if ($list) {
82
-            foreach ($list->getUsers() as $user) {
83
-                $user->setAccessRightList(null);
84
-            }
85
-
86
-            $em->remove($list);
87
-            $em->flush();
88
-
89
-            $this->addFlash("success-flash", "The right list was deleted");
90
-        } else {
91
-            $this->addFlash("error-flash", "The right list wasn't found");
92
-        }
93
-
94
-        return $this->redirectToRoute("ribsadmin_access_rights");
95
-    }
96
-
97
-    /**
98
-     * @param Request $request
99
-     * @param AccessRight $access_right
100
-     * @return RedirectResponse function that handle the form request
101
-     */
102
-    private function handleEditForm(Request $request, AccessRight $access_right): RedirectResponse
103
-    {
104
-        $em = $this->getDoctrine()->getManager();
105
-
106
-        if ($request->get("right") === null) {
107
-            $rights = "";
108
-        } else {
109
-            $rights = implode(",", $request->get("right"));
110
-        }
111
-
112
-        $access_right->setAccessRights($rights);
113
-        $em->persist($access_right);
114
-        $em->flush();
115
-
116
-        $em->getRepository("RibsAdminBundle:AccessRight")->deleteAllUsersList($access_right);
117
-        $admins = $request->get("admins");
118
-
119
-        if ($admins !== null) {
120
-            foreach ($admins as $admin) {
121
-                $em->getRepository("RibsAdminBundle:AccessRight")->setAccessRightListUser($access_right->getId(), $admin);
122
-            }
123
-        }
124
-
125
-        $this->addFlash("success-flash", "The right list was correctly edited");
126
-
127
-        return $this->redirectToRoute("ribsadmin_access_rights");
128
-    }
16
+				/**
17
+				 * @Route("/access-rights-management/", name="ribsadmin_access_rights")
18
+				 * @return Response
19
+				 */
20
+				public function list(): Response
21
+				{
22
+								$em = $this->getDoctrine()->getManager();
23
+								$acces_right = $em->getRepository("RibsAdminBundle:AccessRight")->findAll();
24
+
25
+								return $this->render("@RibsAdmin/access-rights/list.html.twig", [
26
+												"access_right" => $acces_right
27
+								]);
28
+				}
29
+
30
+				/**
31
+				 * @Route("/access-rights-management/create/", name="ribsadmin_access_rights_create")
32
+				 * @Route("/access-rights-management/edit/{guid}", name="ribsadmin_access_rights_edit")
33
+				 * @param Request $request
34
+				 * @param Globals $globals
35
+				 * @param ModuleService $module
36
+				 * @param string|null $guid
37
+				 * @return Response
38
+				 */
39
+				public function edit(Request $request, Globals $globals, ModuleService $module, string $guid = null): Response
40
+				{
41
+								$em = $this->getDoctrine()->getManager();
42
+								$list_rights_user = [];
43
+
44
+								if ($guid === null) {
45
+												$access_right = new AccessRight();
46
+								} else {
47
+												$access_right = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]);
48
+												$list_rights_user = explode(",", $access_right->getAccessRights());
49
+								}
50
+
51
+								$admins = $em->getRepository("RibsAdminBundle:User")->findBy(["admin" => true, "archived" => false]);
52
+
53
+								$form = $this->createForm("PiouPiou\RibsAdminBundle\Form\AccessRight", $access_right);
54
+								$form->handleRequest($request);
55
+
56
+								if ($form->isSubmitted() && $form->isValid()) {
57
+												return $this->handleEditForm($request, $access_right);
58
+								}
59
+
60
+								return $this->render("@RibsAdmin/access-rights/edit.html.twig", [
61
+												"access_right" => $access_right,
62
+												"form" => $form->createView(),
63
+												"form_errors" => $form->getErrors(),
64
+												"list_rights_user" => $list_rights_user,
65
+												"admins" => $admins,
66
+												"ribs_admin_rights" => json_decode(file_get_contents($globals->getBaseBundlePath() . "/Resources/json/ribsadmin_rights.json")),
67
+												"modules" => $module->getAllInfosModules()
68
+								]);
69
+				}
70
+
71
+				/**
72
+				 * @Route("/access-rights-management/delete/{guid}", name="ribsadmin_access_rights_delete")
73
+				 * @param string $guid
74
+				 * @return RedirectResponse function that delete an access right list
75
+				 */
76
+				public function delete(string $guid): RedirectResponse
77
+				{
78
+								$em = $this->getDoctrine()->getManager();
79
+								$list = $em->getRepository("RibsAdminBundle:AccessRight")->findOneBy(["guid" => $guid]);
80
+
81
+								if ($list) {
82
+												foreach ($list->getUsers() as $user) {
83
+																$user->setAccessRightList(null);
84
+												}
85
+
86
+												$em->remove($list);
87
+												$em->flush();
88
+
89
+												$this->addFlash("success-flash", "The right list was deleted");
90
+								} else {
91
+												$this->addFlash("error-flash", "The right list wasn't found");
92
+								}
93
+
94
+								return $this->redirectToRoute("ribsadmin_access_rights");
95
+				}
96
+
97
+				/**
98
+				 * @param Request $request
99
+				 * @param AccessRight $access_right
100
+				 * @return RedirectResponse function that handle the form request
101
+				 */
102
+				private function handleEditForm(Request $request, AccessRight $access_right): RedirectResponse
103
+				{
104
+								$em = $this->getDoctrine()->getManager();
105
+
106
+								if ($request->get("right") === null) {
107
+												$rights = "";
108
+								} else {
109
+												$rights = implode(",", $request->get("right"));
110
+								}
111
+
112
+								$access_right->setAccessRights($rights);
113
+								$em->persist($access_right);
114
+								$em->flush();
115
+
116
+								$em->getRepository("RibsAdminBundle:AccessRight")->deleteAllUsersList($access_right);
117
+								$admins = $request->get("admins");
118
+
119
+								if ($admins !== null) {
120
+												foreach ($admins as $admin) {
121
+																$em->getRepository("RibsAdminBundle:AccessRight")->setAccessRightListUser($access_right->getId(), $admin);
122
+												}
123
+								}
124
+
125
+								$this->addFlash("success-flash", "The right list was correctly edited");
126
+
127
+								return $this->redirectToRoute("ribsadmin_access_rights");
128
+				}
129 129
 }
Please login to merge, or discard this patch.
Controller/ApiController.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -13,69 +13,69 @@
 block discarded – undo
13 13
 
14 14
 class ApiController extends AbstractController
15 15
 {
16
-    /**
17
-     * this method is user to authenticate a user by an api request
18
-     * if success it return a token api that expire in 20 minutes
19
-     * @Route("/api/users/authenticate", name="ribsadmin_api_login", methods={"POST"})
20
-     * @param Request $request
21
-     * @param Api $api
22
-     * @param EncoderFactoryInterface $encoder
23
-     * @return JsonResponse
24
-     * @throws \Exception
25
-     */
26
-    public function login(Request $request, Api $api, EncoderFactoryInterface $encoder): JsonResponse
27
-    {
28
-        $em = $this->getDoctrine()->getManager();
16
+				/**
17
+				 * this method is user to authenticate a user by an api request
18
+				 * if success it return a token api that expire in 20 minutes
19
+				 * @Route("/api/users/authenticate", name="ribsadmin_api_login", methods={"POST"})
20
+				 * @param Request $request
21
+				 * @param Api $api
22
+				 * @param EncoderFactoryInterface $encoder
23
+				 * @return JsonResponse
24
+				 * @throws \Exception
25
+				 */
26
+				public function login(Request $request, Api $api, EncoderFactoryInterface $encoder): JsonResponse
27
+				{
28
+								$em = $this->getDoctrine()->getManager();
29 29
 
30
-        $account = $em->getRepository(Account::class)->findOneBy([
31
-            "username" => $request->get("username"),
32
-        ]);
30
+								$account = $em->getRepository(Account::class)->findOneBy([
31
+												"username" => $request->get("username"),
32
+								]);
33 33
 
34
-        if ($account) {
35
-            if ($encoder->getEncoder($account)->isPasswordValid($account->getPassword(), $request->get("password"), '') === true) {
36
-                if ($account->getisActive() == false) {
37
-                    return new JsonResponse([
38
-                        "success" => false,
39
-                        "error_message" => "You account is disabled"
40
-                    ]);
41
-                }
34
+								if ($account) {
35
+												if ($encoder->getEncoder($account)->isPasswordValid($account->getPassword(), $request->get("password"), '') === true) {
36
+																if ($account->getisActive() == false) {
37
+																				return new JsonResponse([
38
+																								"success" => false,
39
+																								"error_message" => "You account is disabled"
40
+																				]);
41
+																}
42 42
 
43
-                return new JsonResponse([
44
-                    "success" => true,
45
-                    "token" => $api->getToken($account)
46
-                ]);
47
-            }
48
-        }
43
+																return new JsonResponse([
44
+																				"success" => true,
45
+																				"token" => $api->getToken($account)
46
+																]);
47
+												}
48
+								}
49 49
 
50
-        return new JsonResponse([
51
-            "success" => false,
52
-            "error_message" => "bad identifiant and/or password"
53
-        ]);
54
-    }
50
+								return new JsonResponse([
51
+												"success" => false,
52
+												"error_message" => "bad identifiant and/or password"
53
+								]);
54
+				}
55 55
 
56
-    /**
57
-     * method that test if user steel logged and send token or new token if it was expired
58
-     * @Route("/api/users/test-token", name="ribsadmin_api_test_token", methods={"POST"})
59
-     * @param Request $request
60
-     * @param Api $api
61
-     * @param Session $session
62
-     * @return JsonResponse
63
-     * @throws \Exception
64
-     */
65
-    public function testUserToken(Request $request, Api $api, Session $session): JsonResponse
66
-    {
67
-        $test_logged = $api->userIslogged($request->get("infos"), $request->get("token"));
56
+				/**
57
+				 * method that test if user steel logged and send token or new token if it was expired
58
+				 * @Route("/api/users/test-token", name="ribsadmin_api_test_token", methods={"POST"})
59
+				 * @param Request $request
60
+				 * @param Api $api
61
+				 * @param Session $session
62
+				 * @return JsonResponse
63
+				 * @throws \Exception
64
+				 */
65
+				public function testUserToken(Request $request, Api $api, Session $session): JsonResponse
66
+				{
67
+								$test_logged = $api->userIslogged($request->get("infos"), $request->get("token"));
68 68
 
69
-        if ($test_logged === false) {
70
-            return new JsonResponse([
71
-                "success" => $test_logged,
72
-                "error_message" => "Votre compte a été archivé, vous ne pouvez plus vous connecter",
73
-            ]);
74
-        }
69
+								if ($test_logged === false) {
70
+												return new JsonResponse([
71
+																"success" => $test_logged,
72
+																"error_message" => "Votre compte a été archivé, vous ne pouvez plus vous connecter",
73
+												]);
74
+								}
75 75
 
76
-        return new JsonResponse([
77
-            "success" => $test_logged,
78
-            "token" => $api->getToken($session->get("account")),
79
-        ]);
80
-    }
76
+								return new JsonResponse([
77
+												"success" => $test_logged,
78
+												"token" => $api->getToken($session->get("account")),
79
+								]);
80
+				}
81 81
 }
Please login to merge, or discard this patch.
Controller/DefaultController.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
 
8 8
 class DefaultController extends AbstractController
9 9
 {
10
-    /**
11
-     * @Route("/", name="ribsadmin")
12
-     * @Route("/index", name="ribsadmin_index")
13
-     * @Route("/navigation", name="ribsadmin_navigation")
14
-     */
15
-    public function index()
16
-    {
17
-        return $this->render('@RibsAdmin/Default/index.html.twig');
18
-    }
10
+				/**
11
+				 * @Route("/", name="ribsadmin")
12
+				 * @Route("/index", name="ribsadmin_index")
13
+				 * @Route("/navigation", name="ribsadmin_navigation")
14
+				 */
15
+				public function index()
16
+				{
17
+								return $this->render('@RibsAdmin/Default/index.html.twig');
18
+				}
19 19
 }
Please login to merge, or discard this patch.