99 lines
3.7 KiB
HTML
99 lines
3.7 KiB
HTML
{% load static %}
|
|
< <div class="col-lg-8 col-md-8 col-12 mx-auto">
|
|
<div class="page-header min-height-300 border-radius-xl mt-4" style="background-repeat: no-repeat; background-position: cover; background-size:contain; background-image: url('{% static 'img/keys.jpg'%}');">
|
|
<span class="mask bg-gradient-primary opacity-6"></span>
|
|
</div>
|
|
<div class="card mx-3 mx-md-4 mt-n6 h-100 z-index-0 fadeIn3 fadeInBottom " >
|
|
<div class="card-header pb-0 p-3">
|
|
<h6 class="mb-0">Verify your identity using {{ method.name }}</h6>
|
|
</div>
|
|
<div class="card-body">
|
|
|
|
<div class="row">
|
|
<div id="main_paragraph" align="center">
|
|
<p style="color: green">Your key should be flashing now, please press the button.</p>
|
|
{% if mode == "auth" %}
|
|
<form id="u2f_login" action="{% url 'u2f_verify' %}" method="post">
|
|
{% elif mode == "recheck" %}
|
|
<form id="u2f_login" action="{% url 'u2f_recheck' %}" method="post">
|
|
{% endif %}
|
|
{% csrf_token %}
|
|
<input type="hidden" name="response" id="response" value=""/>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
{% if request.session.mfa_methods|length > 1 %}
|
|
<a href="{% url 'mfa_methods_list' %}">Select Another Method</a>
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
</div>
|
|
<script src="{% static 'mfa/js/u2f-api.js' %}" type="text/javascript"></script>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
if (location.protocol != 'https:')
|
|
{
|
|
$("#main_paragraph").addClass("alert alert-danger")
|
|
$("#main_paragraph").html("U2F must work under secure context")
|
|
}
|
|
else {
|
|
|
|
|
|
data = JSON.parse('{{ token|safe }}')
|
|
console.log(data)
|
|
u2f.sign(data.appId, data.challenge, data.registeredKeys, function (response) {
|
|
console.log(response)
|
|
if (response.hasOwnProperty("errorCode") && response.errorCode != 0 )
|
|
{
|
|
if (response.errorCode == 4)
|
|
{
|
|
alert("Invalid Security Key, this security isn't linked to your account")
|
|
}
|
|
else if (response.errorCode == 5)
|
|
{
|
|
alert("Verification Timeout, please refresh the page to try again")
|
|
}
|
|
else
|
|
{
|
|
alert("Unspecified error, please try again later or try another browser.")
|
|
}
|
|
}
|
|
{% if mode == "auth" %}
|
|
else {
|
|
$("#response").val(JSON.stringify(response))
|
|
$("#u2f_login").submit();
|
|
}
|
|
{% elif mode == "recheck" %}
|
|
else {
|
|
$.ajax({
|
|
"url":"{% url 'u2f_recheck' %}",
|
|
method: "POST",
|
|
data: {"csrfmiddlewaretoken":"{{ csrf_token }}","response":JSON.stringify(response)},
|
|
success:function (data) {
|
|
if (data["recheck"]) {
|
|
mfa_success_function();
|
|
}
|
|
else {
|
|
mfa_failed_function();
|
|
}
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
{% endif %}
|
|
}, 5000)
|
|
}
|
|
})
|
|
|
|
|
|
</script>
|