{% 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|escape }}/"><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|escape}}">continue</a> or use the navigation above.
    {% endif %}
  </div>
{% 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|escape }}">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|escape }}" />
    </p>
  </form>
{% endif %}
{% endblock %}

