templates/security/login.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Log in!{% endblock %}
  3. {% block body %}
  4. <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  5. <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
  6.     {{ include('_header.html.twig') }}
  7.     <form method="post" action="{{ path('app_login') }}">
  8.         {% if error %}
  9.             <div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
  10.         {% endif %}
  11.         {% if app.user %}
  12.             <div class="mb-3">
  13.                 Vous êtes déjà connecté en tant que {{ app.user.userIdentifier }}, <a href="{{ path('app_logout') }}">Logout</a>
  14.             </div>
  15.         {% endif %}
  16.         <h1 class="h3 mb-3 font-weight-normal">Connection</h1>
  17.         <label for="inputEmail">Email</label>
  18.         <input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" autocomplete="email" required autofocus>
  19.         <label for="inputPassword">Mot de passe</label>
  20.         <input type="password" name="password" id="inputPassword" class="form-control" autocomplete="current-password" required>
  21.         <input type="hidden" name="_csrf_token"
  22.             value="{{ csrf_token('authenticate') }}"
  23.         >
  24.         <div class="checkbox mb-3">
  25.             <label>
  26.                 <input type="checkbox" name="_remember_me"> Remember me
  27.             </label>
  28.         </div>
  29.         <button class="btn btn-lg btn-primary mt-2" type="submit">
  30.             Se connecter
  31.         </button>
  32.     </form>
  33.     <div class="mt-3">
  34.         <button class="btn btn-lg btn-primary" onclick="forgotPassword()">
  35.             Mot de passe oublié ?
  36.         </button>
  37.     </div>
  38.     {{ include('_footer.html.twig') }}
  39. {% endblock %}
  40. {% block javascripts %}
  41.     <script>
  42.         $(document).ready(function() {
  43.             // check if error in url
  44.             const urlParams = new URLSearchParams(window.location.search);
  45.             const error = urlParams.get('error');
  46.             if(error == 'Email inconnu') {
  47.                 Swal.fire({
  48.                     icon: 'error',
  49.                     title: 'Email inconnu !',
  50.                     text: 'Veuillez rensigner un email d\' un compte existant pour vous demander un nouveau mot de passe.',
  51.                 })
  52.             }
  53.         });
  54.         function forgotPassword() {
  55.             var email = $('#inputEmail').val();
  56.             if(email == '') {
  57.                 Swal.fire({
  58.                     icon: 'error',
  59.                     title: 'Email manquant !',
  60.                     text: 'Veuillez rensigner un email pour vous demander un nouveau mot de passe.',
  61.                 })
  62.             } else {
  63.                 // redirect to app_password_reset path with email
  64.                 window.location.href = "{{ path('app_password_reset') }}?email=" + encodeURIComponent(email);
  65.             }
  66.         }
  67.     </script>
  68. {% endblock %}