<!DOCTYPE html>
<html lang="en">
<head>
    <title>{{ theme.getThemeConfig("theme_title") }}</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="token" content="{{ csrfToken }}"/>
    <meta name="public-path" content="{{ theme.rootUri() }}"/>
    <link rel="shortcut icon" href="{{ theme.uri("img/favicon.ico") }}" />

    <!-- Import CSS bundle from dist -->
    <script src="{{ theme.rootUri() }}dist/style.bundle.min.js?v={{ version }}&rev={{revision}}"></script>

    <!-- Copyright 2006-2021 Xibo Signage Ltd. Part of the Xibo Open Source Digital Signage Solution. Released under the AGPLv3 or later. -->
    <style type="text/css">
        body {
            padding-top: 40px;
            padding-bottom: 40px;
            background-color: #f5f5f5;
        }

        .form-signin {
            max-width: 300px;
            padding: 19px 29px 29px;
            margin: 0 auto 20px;
            background-color: #fff;
            border: 1px solid #e5e5e5;
            -webkit-border-radius: 5px;
            -moz-border-radius: 5px;
            border-radius: 5px;
            -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
            -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
            box-shadow: 0 1px 2px rgba(0,0,0,.05);
        }
        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }
        .form-signin input[type="text"],
        .form-signin input[type="password"] {
            font-size: 16px;
            height: auto;
            margin-bottom: 15px;
            padding: 7px 9px;
        }
        .login-logo {
            width: 200px;
        }

    </style>
</head>
<body>
<div class="container">
        <form id="login-form" class="form-signin text-center" action="{{ url_for("tfa.auth.validate") }}" method="post">
            {% for priorRoute in flash('priorRoute') %}
                <input name="priorRoute" type="hidden" value="{{ priorRoute }}" />
            {% endfor %}
            <input type="hidden" name="{{ csrfKey }}" value="{{ csrfToken }}" />
            <p><a href="{{ theme.getThemeConfig("theme_url") }}"><img class="login-logo" src="{{ theme.uri("img/xibologo.png") }}"></a></p>

            <p>{% trans "Please provide your Two Factor Authorisation Code" %}</p>
            <input id="code" class="form-control input-block-level" name="code" type="text" placeholder="{% trans "Code" %}" autofocus>

            {% if message != '' %}
                <div class="alert alert-danger">{{ message }}</div>
            {% endif %}

            <p><button class="btn btn-primary" type="submit">{% trans "Verify" %}</button></p>

            <p><a href="#" id="recovery-form-toggle">{% trans "Use Recovery Code instead?" %}</a></p>
        </form>

    <form id="recovery-form" class="form-signin text-center d-none" action="{{ url_for("tfa.auth.validate") }}" method="post">
        {% for priorRoute in flash('priorRoute') %}
            <input name="priorRoute" type="hidden" value="{{ priorRoute }}" />
        {% endfor %}
        <input type="hidden" name="{{ csrfKey }}" value="{{ csrfToken }}" />
        <p><a href="{{ theme.getThemeConfig("theme_url") }}"><img class="login-logo" src="{{ theme.uri("img/xibologo.png") }}"></a></p>

        <p>{% trans "Please provide your Two Factor Authorisation Recovery Code" %}</p>
        <input id="recoveryCode" class="form-control input-block-level" name="recoveryCode" type="text" placeholder="{% trans "Recovery Code" %}" autofocus>

        {% for loginMessage in flash('2fa_message') %}
            <div class="alert alert-danger">{{ loginMessage }}</div>
        {% endfor %}

        <p><button class="btn btn-primary" type="submit">{% trans "Verify" %}</button></p>

        <p><a href="#" id="login-form-toggle">{% trans "Use Two Factor Code instead?" %}</a></p>
    </form>
</div>
<!-- Import JS bundle from dist -->
<script src="{{ theme.rootUri() }}dist/vendor.bundle.min.js?v={{ version }}&rev={{revision}}"></script>
<script type="text/javascript">
    $(function() {
        $("#recovery-form-toggle").on("click", function (e) {
            e.preventDefault();

            $("#login-form").addClass("d-none");
            $("#recovery-form").removeClass("d-none");
        });

        $("#login-form-toggle").on("click", function (e) {
            e.preventDefault();

            $("#login-form").removeClass("d-none");
            $("#recovery-form").addClass("d-none");
        });
    });
</script>
</body>
</html>
