{% extends "website/w_base.html" %}

{% block content %}
{% if with_shop_header %}
    {% include "shop/connect_header.html" %}
{% endif %}
<div id="connect_form_template" style="text-align:center;">
        <form method="POST">
            <p><input type="text" name="login" placeholder="Email" /></p>
            <p>
                <input type="password" name="password" placeholder="{{password_placeholder}}" />
                {% if password_notice %}
                 <br/>
                 <span style="font-size: small;font-style: italic;">{{password_notice}}</span>
                {% endif %}
                
            </p>
            {% csrf_token %}
            <input type="hidden" name="fp" value="" />
            <p><button type="submit">Connexion</button></p>
        </form>
        <p style="color:red;">{{msg}}</p>
        <!--<p><a href="oubli_pass">Mot de passe oubliƩ</a></p>-->
        <script>
            try {
                window.addEventListener("DOMContentLoaded", (event) => {
                    var fp = document.getElementsByName('fp')
                    if (fp.length == 1)
                        fp[0].value = new Fingerprint({canvas: true}).get()
                })
            } catch (e) {
                var msg = 'Ce navigateur ne permet pas de vous identifier. Merci de signaler l\'erreur suivante:\n'
                msg += JSON.stringify(e)
                alert(msg)
            }
        </script>
</div>

<script>
    // For the members space, reset url to home when accessing connect page
    const is_member_space = '{{is_member_space}}';

    if (is_member_space === "True") {
        var app_env = '{{app_env}}';
        var base_location = (app_env === 'dev') ? '/members_space/' : '/';
        if (window.location.pathname === base_location) {
            history.pushState({}, '', 'home');
        } else {
            history.replaceState({}, '', 'home');
        }
    }
</script>
{% endblock %}