<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Inactive expiry</title>
  <link rel="stylesheet" href="../style.css">
</head>
<body class="container">

  <nav class="py-4">
    <a href=".">&laquo; Back to Auth</a>
  </nav>

  <section>
    <h1>Inactive Expiry example</h1>

    {% if error %}
      <div class="alert alert-danger">
        <h2>Error logging in</h2>
        <p><strong>code</strong> {{ error['code'] }}</p>
        <p><strong>error</strong> {{ error['error'] }}</p>
      </div>
    {% end %}

    {% import time %}
    {% import json %}
    {% import gramex %}
    {% if handler.current_user %}
      <p>Your are logged in as:</p>
      <div class="codehilite"><pre>{{ json.dumps(handler.current_user, indent=4) }}</pre></div>
    {% else %}
      <p>You are not logged in.</p>
    {% end %}

    {% if '_i' in handler.session %}
      <p>You must visit this page again in {{ '{:,.0f}'.format(handler.session['_i'] + handler.session['_l'] - time.time()) }} seconds</p>
    {% else %}
      <p>Currently, no inactive expiry is specified for your session.</p>
    {% end %}

    <p>You can log in below as <code>alpha</code> with password <code>alpha</code>.
      When you log in, your session will be inactivated (if not visited) in
      {{ '{:,.0f}'.format(handler.kwargs.session_inactive * 24 * 60 * 60) }} seconds.
      But when you log in through other login pages like <a href="simple">simple</a>,
      the session will stay active.</p>

    <form method="POST">
      <input type="hidden" name="_xsrf" value="{{ handler.xsrf_token }}">
      <div class="form-group">
        <label for="user">Username</label>
        <input name="user" class="form-control" placeholder="Username">
      </div>
      <div class="form-group">
        <label for="password">Password</label>
        <input name="password" type="password" class="form-control" placeholder="Password">
      </div>
      <button type="submit" class="btn btn-primary">Log in</button>
    </form>
  </section>

</body>
</html>
