{% extends "master.html" %}

{% block title %}Log in{% endblock %}

{% block content %}

{% if session %}
<h2>Logged in</h2>
<div class="flash-notice">
    You are now logged in as <a href="{{uriPrefix}}/persons/{{ session.person.name }}/"><strong>{% firstof session.person.fullname session.person.name %}</strong></a>. 
  {% if returnPath %}
    If you're not automatically redirected to where you were, please <a href="{{returnPath}}">continue</a> or use the navigation above.
  {% endif %}
</div>

  {% if view.canApprovePersons %}
    {% if view.registry.persons.getPending.count %}
<div class="flash-notice">
    <a href="{{ uriPrefix }}/persons/pending/"><b>
    There are {{ view.registry.persons.getPending.count }}
    pending registrations.
    </b></a>
</div>
    {% endif %}
  {% endif %}

{% else %}
<h2>Log in</h2>

  {% if isAuthenticateFail %}
  <div class="flash-error">
    Sorry, wrong user name or password.
  </div>
  {% else %}
    {% if returnPath %}
  <div class="flash-error">
    You'll need to log in before you can access this area.
  </div>
    {% endif %}
  {% endif %}

  <form action="{{uriPrefix}}/login/" method="post" id="">
    <p>

  {% if canCreatePerson %}
      <a href="{{uriPrefix}}/persons/create/{{ returnPath }}">Register</a> or log in:
  {% else %}
      Please log in now:
  {% endif %}
      <label for="name">User name:</label>
      <input type="text" id="name" name="name" title="Name" />

      <label for="password">Password:</label>
      <input type="password" id="password" name="password" title="Password" />

      <label for="submit"></label>
      <input type="submit" id="submit" name="submit" value="Log in &raquo;" />

      <input type="hidden" name="returnPath" value="{{ returnPath }}" />
    </p>
  </form>
{% endif %}
{% endblock %}

