{% extends 'base.html.twig' %}
{% block title %}Admin Digidom{% endblock %}
{% block body %}
<div class="row vh-100">
<div class="col-md-3 d-flex justify-content-center align-items-center align-items-md-start pt-md-4"
style="background: #353535; box-shadow: 5px 0 30px 0px #353535; border-right: 1px solid #aaa;">
<img src="{{ asset('img/logo.png') }}" style="width: 50%;"/>
</div>
<div class="col-12 col-md-6 d-flex align-items-center px-5">
<form method="post" class="mx-auto col-12 col-md-8">
{% if error %}
<div class="alert alert-danger">{{ error }}</div>
{% endif %}
<h1 class="h3 mb-3 font-weight-normal">Confirmation authentification</h1>
<label for="inputConfirmation" class="pt-3">Veuillez entrer le code envoyé dans votre email</label>
<div class="input-group">
<input type="text" maxlength="6" name="code_confirmation" id="inputConfirmation"
class="form-control"
required autofocus>
<div class="input-group-append">
<a class="btn btn-primary" id="resend_code" style="color:white;" data-email="{{ userEmail }}">
Renvoyer le code
</a>
</div>
</div>
<input type="hidden" name="_csrf_token"
value="{{ csrf_token('authenticate') }}"
>
<br>
<button class="btn btn-primary mt-3" type="submit">
Valider
</button>
</form>
</div>
<div class="col-md-3"></div>
</div>
<script>
$('#resend_code').on('click', function () {
var content = $(this);
$.ajax({
method: "POST",
url: "/v1/send-back-code",
contentType: 'application/json',
data: JSON.stringify(
{
"email": content.data('email')
}
),
dataType: "json"
})
.done(function (msg) {
if(msg == 'success') {
$("#resend_code").prepend('<span class="fa fa-check"></span>').addClass('btn-success').prop('disabled', true);
} else {
$("#resend_code").prepend('<span class="fa fa-times"></span>').addClass('btn-danger').prop('disabled', true);
}
});
});
</script>
{% endblock %}