<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:py="http://genshi.edgewall.org/"
  xmlns:xi="http://www.w3.org/2001/XInclude"
  py:strip="True">

<?python
  from fedora.tg.controllers import f_
?>

<py:match path="loginform" once="true">
  <div class="panel">
    <div id="login-box" class="login">
      <h3>${f_('Log In')}</h3>
      <p py:content="unicode(select('*|text()'))" />
      <form py:if="not tg.identity.only_token"
        action="${tg.url(previous_url)}" method="post">
        <div class="field"><label for="user_name">${f_('User Name:')}</label>
          <input type="text" id="user_name" name="user_name" />
        </div>
        <div class="field"><label for="password">${f_('Password:')}</label>
          <input type="password" id="password" name="password" />
        </div>
        <div class="field">
          <input type="submit" name="login" class="button"
            value="${f_('Login')}" />
          <hiddenvals />
        </div>
      </form>
      <form py:if="tg.identity.only_token"
        action="${tg.url(previous_url)}" method="post">
        <p><a href="http://en.wikipedia.org/wiki/CSRF">${f_('CSRF attacks')}</a>
        ${f_(''' are a means for a malicious website to make a request of another
        web server as the user who contacted the malicious web site.  The
        purpose of this page is to help protect your account and this server
        from attacks from such malicious web sites.  By clicking below, you are
        proving that you are a person rather than just the web browser
        forwarding your authentication cookies on behalf of a malicious
        website.''')}</p>
        <input type="submit" name="csrf_login" class="button"
          value="${f_('I am a human')}" />
        <hiddenvals />
      </form>
      <ul>
        <li><a href="${tg.url(tg.config('fas.url', 'https://admin.fedoraproject.org/accounts').rstrip('/') + '/user/resetpass')}">${f_('Forgot Password?')}</a></li>
        <li><a href="${tg.url(tg.config('fas.url', 'https://admin.fedoraproject.org/accounts').rstrip('/') + '/user/new')}">${f_('Sign Up')}</a></li>
      </ul>
    </div>
  </div>
</py:match>

<py:match path="hiddenvals" once="true">
  <input py:if="forward_url" type="hidden" name="forward_url"
    value="${forward_url}" />
  <div py:for="name,values in original_parameters.items()" py:strip="1">
    <input py:for="value in isinstance(values, list) and values or [values]"
      py:if="name != '_csrf_token'" type="hidden" name="${name}"
      value="${value}"/>
  </div>
</py:match>

<py:match path="logintoolitem" once="true">
  <li py:if="not tg.identity.anonymous" class="toolitem">
    ${f_('Welcome')}
    <div py:choose="unicode(select('@href'))" py:strip="True">
      <span py:when="''" py:choose="" py:strip="True">
        <span py:when="hasattr(tg.identity.user, 'display_name')"
          py:replace="tg.identity.user.display_name" />
        <span py:when="hasattr(tg.identity.user, 'human_name')"
          py:replace="tg.identity.user.human_name" />
        <span py:otherwise="" py:replace="tg.identity.user_name" />
      </span>
      <a py:otherwise="" href="${select('@href')}" py:choose=""
        py:strip="True">
        <span py:when="hasattr(tg.identity.user, 'display_name')"
          py:replace="tg.identity.user.display_name" />
        <span py:when="hasattr(tg.identity.user, 'human_name')"
          py:replace="tg.identity.user.human_name" />
        <span py:otherwise=""
          py:replace="tg.identity.user_name" />
      </a>
    </div>
  </li>
  <li py:if="tg.identity.anonymous and not tg.identity.only_token"
    id="login-toolitem" class="toolitem">
    ${f_('You are not logged in')}
    <form action="${tg.url('/login')}" method="POST">
      <input type="submit" value="${f_('Login')}" class="button" />
    </form>
  </li>
  <li py:if="tg.identity.anonymous and tg.identity.only_token"
    id="login-toolitem" class="toolitem">
    ${f_('CSRF protected')}
    <form action="${tg.url(tg.request.path_info)}" method="POST">
      <input type="submit" name="csrf_login" value="${f_('Verify Login')}" class="button" />
    </form>
  </li>
  <li py:if="not tg.identity.anonymous or tg.identity.only_token"
    id="login-toolitem" class="toolitem">
    <form action="${tg.url('/logout')}" method="POST">
      <input type="submit" value="${f_('Logout')}" class="button" />
    </form>
  </li>
</py:match>
</html>
