From 6c07fa278f0e8e45de9bb5dd1ab017300f8521df Mon Sep 17 00:00:00 2001 From: ExostFlash <120869320+ExostFlash@users.noreply.github.com> Date: Thu, 23 Nov 2023 11:35:50 +0100 Subject: [PATCH] Block acces to admin --- config/packages/security.yaml | 2 +- config/packages/translation.yaml | 10 +++++----- src/Entity/User.php | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/config/packages/security.yaml b/config/packages/security.yaml index 7148954..fa1c71f 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -31,7 +31,7 @@ security: # Easy way to control access for large sections of your site # Note: Only the *first* access control that matches will be used access_control: - # - { path: ^/admin, roles: ROLE_ADMIN } + - { path: ^/admin, roles: ROLE_Root } # - { path: ^/profile, roles: ROLE_USER } when@test: diff --git a/config/packages/translation.yaml b/config/packages/translation.yaml index abb76aa..2c2320c 100644 --- a/config/packages/translation.yaml +++ b/config/packages/translation.yaml @@ -1,9 +1,9 @@ framework: - default_locale: en - translator: - default_path: '%kernel.project_dir%/translations' - fallbacks: - - en + default_locale: fr + translator: + default_path: "%kernel.project_dir%/translations" + fallbacks: + - fr # providers: # crowdin: # dsn: '%env(CROWDIN_DSN)%' diff --git a/src/Entity/User.php b/src/Entity/User.php index 52de2a8..69702c5 100644 --- a/src/Entity/User.php +++ b/src/Entity/User.php @@ -80,6 +80,9 @@ class User implements UserInterface, PasswordAuthenticatedUserInterface public function getRoles(): array { $roles = $this->roles; + $grade = $this->grade; + + $roles[] = "ROLE_" . (string)$grade; return array_unique($roles); }