<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>Forbidden</title>
  <!-- htmllint tag-bans="false" -->
  <style>
  * { box-sizing: border-box; }
  html { width: 100%; height: 100%; }
  h1, p { text-align: center; }
  body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: 18px; }
  .content { margin: 0 auto; max-width: 40rem; }
  pre { white-space: pre-wrap; background-color: #f8f8f8; padding: 0.5em; overflow-x: auto; }
  pre code { white-space: pre; }
  table { margin: 0 auto; }
  th, td { text-align: left; border-bottom: 1px solid #eee; padding: 0.5rem 0.5rem 0.5rem 0; vertical-align: top; }
  #traceback { display: none; }
  #show-traceback { position: fixed; bottom: 0; width: 100%; text-align: center; cursor: pointer; opacity: 0.4; }
  </style>
  <!-- htmllint tag-bans="$previous" -->
</head>
<body>
  <section class="content">
    <h1>You need access</h1>
    {% try %}{% set xsrf = handler.check_xsrf_cookie() or True %}{% except %}{% set xsrf = False %}{% end %}
    {% set login_url = None %}
    {% try %}{% set login_url = handler.kwargs.auth.login_url %}{% except %}
      {% try %}{% import gramex %}{% set login_url = gramex.conf.app.settings.login_url %}{% except %}{% end %}
    {% end %}
    {% if handler.request.method not in {'GET', 'HEAD', 'OPTIONS'} and not xsrf %}
      <p>Your app sent a {{ handler.request.method }} request without an XSRF cookie.</p>
    {% elif handler.current_user %}
      <p>You are logged in, but as a user that cannot access this page.</p>
      {% import yaml %}
      <pre>{{ yaml.safe_dump(handler.current_user, default_flow_style=False) }}</pre>
      {% if login_url %}<p><a href="{{ login_url }}">Try logging in again</a>.</p>{% end %}
    {% else %}
      <p>You <strong>are not</strong> logged in.</p>
      {% if login_url %}<p><a href="{{ login_url }}">Try logging in</a>.</p>{% end %}
    {% end %}
    <p>Contact the app owner for more information.</p>
    {% set exception = kwargs['exc_info'][1] %}
    <table><tbody>
      {% for key, val in vars(exception).items() %}
        {% if val %}
          <tr><th>{{ key.replace('_', ' ').title() }}</th><td>{{ val }}</td></tr>
        {% end %}
      {% end %}
    </tbody></table>
  </section>
</body>
</html>
