{% extends "login/layout/sidebar-layout.html.twig" %}

{% import "common/macro_captcha.html.twig" as macro_captcha %}
{% import "login/common/macros.html.twig" as auth_macro %}

{% block title %}
    {{ "Login" | trans }}
{% endblock %}

{% block sidebar %}
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12">
                <div class="text-title">
                    {{ "Connection" | trans }}
                </div>
                <div class="match-hint">
                    {% set provider_name = provider.getName() %}
                    {% trans with {'%provider_name%' : provider_name} %}Your %provider_name% account matchs a Phraseanet account{% endtrans %}
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                {{ auth_macro.providerBadge(token) }}
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                <div class="text-center well-small">
                 <img src="/assets/authentication/images/link.png" style="height:30px;"/>
                </div>
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                {{ auth_macro.phraseanetBadge(suggestion) }}
            </div>
        </div>
    </div>
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 sidebar-hint-large">
                {{ "Login to link your account" | trans }}
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12">
                {{ auth_macro.flashes() }}
                <form
                    novalidate
                    name="loginForm"
                    action="{{ path('login_authentication_provider_do_mapping', { 'providerId' : provider.getId() }) }}"
                    method="POST"
                >
                    {% if form.vars.errors|length > 0 %}
                        <div class="row-fluid">
                            <div class="span12">
                                {{ form_errors(form) }}
                            </div>
                        </div>
                    {% endif %}
                    <div class="row-fluid hidden">
                        <div class="span12">
                            {{ auth_macro.fieldInput(form.login, "loginForm", 'fa fa-envelope', {'value' : 'nard', 'autocomplete' : 'off' }) }}
                        </div>
                    </div>
                    <div class="row-fluid">
                        <div class="span12">
                            {{ auth_macro.fieldInput(form.password, "loginForm", 'fa fa-lock') }}
                        </div>
                    </div>
                    <div class="text-right">
                        <a class="forget-password-link" href="{{ path("login_forgot_password") }}">{{ "Forgot password?" | trans }}</a>
                    </div>
                    {% if recaptcha_display %}
                        <div class="row-fluid">
                            <div class="span12">
                                {{ macro_captcha.captcha() }}
                            </div>
                        </div>
                    {% endif %}

                    {{ form_rest(form) }}

                    <div class="row-fluid">
                        <div class="span12">
                            <button type="submit" class="btn btn-success btn-trigger">
                                {{ "Connection" | trans }}
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <div class="well-large sidebar-block">
        <div class="row-fluid">
            <div class="span12 text-center">
                {{ "These informations do not match?" | trans }}
            </div>
        </div>
        <div class="row-fluid">
            <div class="span12 text-center">
                <a href="{{ path("homepage") }}" class="btn btn-info btn-trigger">
                    {{ "Use my Phraseanet account" | trans }}
                </a>
            </div>
        </div>
    </div>
    {% include "login/include/register-link-block.html.twig" with {"last_item" : register_enable} %}
{% endblock %}

{% block scripts %}
    {{ parent() }}
    <script>
        authenticateApp.bootstrap({
            state: 'login'
        })
    </script>
{% endblock %}
