diff --git a/assets/app.js b/assets/app.js index 4e44013..089beb5 100644 --- a/assets/app.js +++ b/assets/app.js @@ -8,23 +8,22 @@ import 'bootstrap'; import $ from 'jquery'; //endregion //region Utils -import Utils from 'utils'; window.$ = $; // Declare $ as a global variable, accessible in all files //endregion -//region Header & Footer fixe (overlay) -const headerHeight = Utils.getElementRealHeight($('header:not(.overlay-not-fixed)')); -const footerHeight = Utils.getElementRealHeight($('footer:not(.overlay-not-fixed)')); -$('#div-body').css( - { - 'padding-top': headerHeight, - 'padding-bottom': footerHeight, - }, -); -$('html').css( - { - 'scroll-padding-top': headerHeight, - }, -); -//endregion \ No newline at end of file +////region Header & Footer fixe (overlay) +//const headerHeight = Utils.getElementRealHeight($('header:not(.overlay-not-fixed)')); +//const footerHeight = Utils.getElementRealHeight($('footer:not(.overlay-not-fixed)')); +//$('#div-body').css( +// { +// 'padding-top': headerHeight, +// 'padding-bottom': footerHeight, +// }, +//); +//$('html').css( +// { +// 'scroll-padding-top': headerHeight, +// }, +//); +////endregion \ No newline at end of file diff --git a/assets/styles/_layout.scss b/assets/styles/_layout.scss index 7300cec..86cce84 100644 --- a/assets/styles/_layout.scss +++ b/assets/styles/_layout.scss @@ -15,4 +15,12 @@ header { } footer { bottom : 0; +} + +#div-body { + padding-top : 21px; + padding-bottom : 0; +} +html { + scroll-padding-top : 21px } \ No newline at end of file diff --git a/src/Controller/UserController.php b/src/Controller/UserController.php index 7f82acd..2f09d85 100644 --- a/src/Controller/UserController.php +++ b/src/Controller/UserController.php @@ -3,6 +3,7 @@ namespace App\Controller; use App\Entity\User; +use App\Form\SignInFormType; use App\Form\SignUpFormType; use App\Repository\UserRepository; use App\Security\EmailVerifier; @@ -21,6 +22,10 @@ use Symfony\Contracts\Translation\TranslatorInterface; use SymfonyCasts\Bundle\VerifyEmail\Exception\VerifyEmailExceptionInterface; class UserController extends AbstractController { + /** + * @var TranslatorInterface The translator service + */ + private readonly TranslatorInterface $translator; /** * @var EmailVerifier The email verifier service */ @@ -29,16 +34,18 @@ class UserController extends AbstractController { /** * Initialisation * - * @param EmailVerifier $emailVerifier The email verifier service + * @param TranslatorInterface $translator The translator service + * @param EmailVerifier $emailVerifier The email verifier service */ - public function __construct (EmailVerifier $emailVerifier) { + public function __construct (TranslatorInterface $translator, EmailVerifier $emailVerifier) { + $this->translator = $translator; $this->emailVerifier = $emailVerifier; } /** * Register a new user * - * @param Request $request The query + * @param Request $request The request * @param UserPasswordHasherInterface $userPasswordHasher The password hashing service * @param EntityManagerInterface $entityManager The entity manager * @@ -126,12 +133,13 @@ class UserController extends AbstractController { /** * Sign in a user * + * @param Request $request The request * @param AuthenticationUtils $authenticationUtils Security errors from query * * @return Response The response */ #[Route(path: '/signIn', name: 'user_signIn')] - public function login (AuthenticationUtils $authenticationUtils): Response { + public function login (Request $request, AuthenticationUtils $authenticationUtils): Response { /** @var User|null $user */ $user = $this->getUser(); if ($user !== null) { @@ -141,14 +149,13 @@ class UserController extends AbstractController { ); } - $error = $authenticationUtils->getLastAuthenticationError(); - - $lastUsername = $authenticationUtils->getLastUsername(); + if (($error = $authenticationUtils->getLastAuthenticationError()) !== null) { + $this->addFlash('danger', $this->translator->trans($error->getMessageKey(), $error->getMessageData(), 'security')); + } return $this->render( 'user/signIn.html.twig', [ - 'last_username' => $lastUsername, - 'error' => $error, + 'last_username' => $authenticationUtils->getLastUsername(), ] ); } diff --git a/src/Security/UserChecker.php b/src/Security/UserChecker.php index 6d96073..fe9231c 100644 --- a/src/Security/UserChecker.php +++ b/src/Security/UserChecker.php @@ -9,6 +9,10 @@ use Symfony\Component\Security\Core\User\UserInterface; /** * Check if a user is valid for authentification + * + * The user must have: + * - Verified his email + * - Account validated by administrator */ class UserChecker implements UserCheckerInterface { /** @@ -20,10 +24,10 @@ class UserChecker implements UserCheckerInterface { } if (!$user->isVerified()) { - throw new CustomUserMessageAccountStatusException('Your account mail has not been validated.'); + throw new CustomUserMessageAccountStatusException('user.emailNotVerified'); } if ($user->getValidationAdministrator() === null || $user->getValidationDate() === null) { - throw new CustomUserMessageAccountStatusException('Your account has not been validated by an administrator yet.'); + throw new CustomUserMessageAccountStatusException('user.notValidatedByAdmin'); } } /** diff --git a/templates/_flashes.html.twig b/templates/_flashes.html.twig index 0bfa03b..a9a0988 100644 --- a/templates/_flashes.html.twig +++ b/templates/_flashes.html.twig @@ -1,12 +1,15 @@ {% block flashTag %} -
- {% endblock %} - {% for flashType, flashMessages in app.flashes %} - {% for flashMessage in flashMessages %} -
- {{ flashMessage }} - -
- {% endfor %} - {% endfor %} -
\ No newline at end of file + {% set flashes = app.flashes %} + {% if flashes|length > 0 %} +
+ {% for flashType, flashMessages in flashes %} + {% for flashMessage in flashMessages %} +
+ {{ flashMessage }} + +
+ {% endfor %} + {% endfor %} +
+ {% endif %} +{% endblock %} \ No newline at end of file diff --git a/templates/base.html.twig b/templates/base.html.twig index 6cfae3e..689b4ac 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -1,5 +1,7 @@ {% extends "/symfony.html.twig" %} +{% block title %}Web EDM{% endblock %} + {% block headerTag %}
{% endblock %} @@ -13,8 +15,8 @@