<!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}}" nonce="{{ cspNonce }}"></script>

    <!-- Copyright 2006-2023 Xibo Signage Ltd. Part of the Xibo Open Source Digital Signage Solution. Released under the AGPLv3 or later. -->
    <style type="text/css">
        html {
            font-size: 14px;
        }

        body {
            padding-top: 40px !important;
            padding-bottom: 40px !important;
            background-color: #f5f5f5;
            font-size: 1rem;
        }

        .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: 1.15rem;
            height: auto;
            margin-bottom: 15px;
            padding: 7px 9px;
        }
        .login-logo {
            width: 200px;
        }

    </style>
    <!-- Import user made CSS from theme -->
    <link href="{{ theme.uri("css/override.css") }}?{{ version }}" rel="stylesheet" media="screen">
</head>
<body>
    <div class="container">
        {% if authCASEnabled %}
        <form id="cas-login-form" class="form-signin text-center" action="{{ url_for("cas.login") }}" method="post">
            {% for priorRoute in flash('priorRoute') %}
                <input name="priorRoute" type="hidden" value="{{ priorRoute }}" />
            {% endfor %}
            <p><img alt="Logo" class="login-logo" src="{{ theme.uri("img/xibologo.png") }}"></p>

            <p>{% trans  %}Connect with the Central Authentication Server{% endtrans %}</p>

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

            <p><button class="btn btn-primary" type="submit" name="logincas">{% trans %} CAS Login{% endtrans %}</button></p>
        </form>
        {% else %}
        <form id="login-form" class="form-signin text-center" action="{{ url_for("login") }}" 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 credentials" %}</p>

            <input id="username" class="form-control input-block-level" name="username" type="text" placeholder="{% trans "User" %}" autofocus autocomplete="username">
            <input id="password" class="form-control input-block-level" name="password" type="password" placeholder="{% trans "Password" %}" autocomplete="current-password">

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

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

            {% if passwordReminderEnabled %}<p><a href="#" id="reminder-form-toggle">{% trans "Forgotten your password?" %}</a></p>{% endif %}
        </form>
        {% endif %}

        {% if passwordReminderEnabled %}
        <form id="reminder-form" class="form-signin text-center d-none" action="{{ url_for("login.forgotten") }}" method="post">
            <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 user name" %}</p>
            <input id="username" class="form-control input-block-level" name="username" type="text" placeholder="{% trans "User" %}">

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

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

            <p><a href="#" id="login-form-toggle">{% trans "Login instead?" %}</a></p>
        </form>
        {% endif %}

        <p class="text-center">{% trans %}Version {{ version }}{% endtrans %}
            | <a id="source-link" href="{{ theme.getThemeConfig("cms_source_url") }}">{% trans "Source" %}</a>
            | <a id="about-link" class="XiboFormButton" href="{{ url_for("about") }}" title="{% trans "About" %}">{% trans "About" %}</a>
        </p>
    </div> <!-- /container -->
    <!-- Import JS bundle from dist -->
    <script src="{{ theme.rootUri() }}dist/vendor.bundle.min.js?v={{ version }}&rev={{revision}}" nonce="{{ cspNonce }}"></script>
    <script type="text/javascript" nonce="{{ cspNonce }}">
        $(function() {
            $("#reminder-form-toggle").on("click", function (e) {
                e.preventDefault();

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

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

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