<form id="login_form" action="<%= url_for :controller => 'sessions', :action => 'login' -%>" method="post">
  <input type="hidden" name="return_to_anchor" value="<%= @return_to_anchor %>">

  <h1 class="maintenance-title text-center">Log In to SonarQube</h1>

  <% if flash[:loginerror] %>
    <div class="alert alert-danger"> <%= flash[:loginerror] %></div>
  <% end %>
  <% if flash[:notice] %>
    <div class="alert alert-info"><%= flash[:notice] %></div>
  <% end %>

  <div class="big-spacer-bottom">
    <label for="login" class="login-label"><%= message('login') %></label>
    <input type="text" id="login" name="login" class="login-input" maxlength="255" required
           placeholder="<%= message('login') %>">
    <% if Property.value('sonar.allowUsersToSignUp')=='true' %>
      <p class="note spacer-top spacer-left spacer-right">
        <%= message('sessions.new_account', :params => [url_for(:controller => 'users', :action => 'new')]) -%>
      </p>
    <% end %>
  </div>

  <p class="big-spacer-bottom">
    <label for="password" class="login-label"><%= message('password') %></label>
    <input type="password" id="password" name="password" class="login-input" required
           placeholder="<%= message('password') %>">
  </p>

  <p class="big-spacer-bottom">
    <input class="login-remember-me" id="remember_me" name="remember_me" type="checkbox" value="1" checked>
    <label for="remember_me"></label>
    <label for="remember_me"><%= message('sessions.remember_me') -%></label>
  </p>

  <p class="text-right">
    <button name="commit"><%= message('sessions.log_in') -%></button>
    <a class="spacer-left" href="<%= home_path -%>"><%= message('cancel') -%></a>
  </p>
</form>

<script>
  (function ($) {
    $('#login').focus();
    var returnToAnchor = $('[name="return_to_anchor"]');
    if (!returnToAnchor.val()) {
      returnToAnchor.val(window.location.hash);
    }
  })(window.jQuery);
</script>
