templates/security/login.html.twig line 1

Open in your IDE?
  1. {% extends 'layout_web.html.twig' %}
  2. {% block title %}{{ 'login.title'|trans }} | {{parent()}}{% endblock %}
  3. {% block body %}
  4.     <div class="page">
  5.       <div class="page-single">
  6.         <div class="container">              
  7.           <div class="row">
  8.             <div class="col col-md-5 mx-auto">
  9.                 <div class="text-center mb-6">
  10.                   <img src="{{ asset('/images/logo-pbn-200x100.png')}}" alt="{{appname}}">                    
  11.                 </div>
  12.                 {% if app.user %}
  13.                 <div class="text-center">
  14.                     <h4>{{ 'login.alreadylogin'|trans }} {{ app.user.username }}</h4> 
  15.                     <p><a href="{{ path('app_logout') }}">{{ 'login.logout'|trans }}</a></p>
  16.                 </div>
  17.                 {% else %}
  18.                 
  19.                 {% if error %}
  20.                     <div class="alert alert-danger">{{ error.messageKey|trans(error.messageData, 'security') }}</div>
  21.                 {% endif %}
  22.                 {% for flash in app.flashes('success') %}
  23.                     <div class="alert alert-success" role="alert">{{ flash }}</div>
  24.                 {% endfor %}
  25.                 {% for flash in app.flashes('error') %}
  26.                     <div class="alert alert-danger" role="alert">{{ flash }}</div>
  27.                 {% endfor %}
  28.               <form class="card" action="" method="post">
  29.             
  30.                 <div class="card-body p-6">
  31.                  <div class="float-right">
  32.                     <a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': ''})) }}"><span class="flag flag-fr mr-3"></span></a>
  33.                     <a href="{{ path(app.request.get('_route'), app.request.get('_route_params')|merge({'_locale': 'en'})) }}"><span class="flag flag-gb"></span></a>
  34.                 </div>
  35.                   <div class="card-title">{{ 'login.title'|trans }}</div>                 
  36.                   <div class="form-group">
  37.                     <label for="inputEmail" class="form-label">{{ 'login.email'|trans }}</label>
  38.                     <input type="email" value="{{ last_username }}" name="email" id="inputEmail" class="form-control" autocomplete="email" required autofocus>
  39.                   </div>
  40.                   <div class="form-group">
  41.                   <label for="inputPassword" class="form-label">
  42.                   {{ 'login.password'|trans }}
  43.                   <a href="{{ path('app_forgot_password_request') }}" class="float-right small">{{ 'login.resetpassword'|trans }}</a>
  44.                   </label>
  45.                   <input type="password" name="password" id="inputPassword" class="form-control" autocomplete="current-password" required>
  46.                   <i class="fe fe-eye-off" id="togglePassword"></i>
  47.                   </div>
  48.                   <div class="form-group">
  49.                     <label class="custom-control custom-checkbox">
  50.                     <input type="checkbox" name="_remember_me" class="custom-control-input"> <span class="custom-control-label">{{ 'login.remember'|trans }}</span>
  51.                     </label>
  52.                   </div>
  53.                   <div class="form-footer">
  54.                     <button type="submit" class="btn btn-primary btn-block"> {{ 'login.signin'|trans }}</button>
  55.                   </div>
  56.                 </div>
  57.                 <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}" >
  58.               </form>
  59.               <div class="text-center text-muted">
  60.                 <a href="{{ path('app_register') }}">{{ 'login.newaccount'|trans }}</a>
  61.               </div>
  62.             </div>
  63.           </div>
  64.         </div>
  65.       </div>
  66.     </div>
  67. {% endif %}
  68. <style>
  69.     #togglePassword {
  70.     position: absolute;
  71.     right: 1.5em;
  72.     cursor: pointer;
  73.     margin-right: 25px;
  74.     margin-top: -27px;
  75. }
  76. </style>
  77. <script>
  78.         const togglePassword = document.querySelector("#togglePassword");
  79.         const password = document.querySelector("#inputPassword");
  80.         togglePassword.addEventListener("click", function () {
  81.             // toggle the type attribute
  82.             const type = password.getAttribute("type") === "password" ? "text" : "password";
  83.             password.setAttribute("type", type);            
  84.             // toggle the icon
  85.             if (type == "text") {
  86.             this.classList.remove("fe-eye-off");
  87.             this.classList.add("fe-eye");
  88.             }
  89.             if (type == "password") {
  90.             this.classList.remove("fe-eye");
  91.             this.classList.add("fe-eye-off");
  92.             }
  93.         });
  94. </script>
  95. {% endblock %}