97 lines
2.8 KiB
HTML
97 lines
2.8 KiB
HTML
|
|
{% extends "base.html" %}
|
|
{% load static %}
|
|
{% block head %}
|
|
<style>
|
|
#two-factor-steps {
|
|
border: 1px solid #ccc;
|
|
border-radius: 3px;
|
|
padding: 15px;
|
|
}
|
|
.tokenrow{
|
|
margin-top: 10px;
|
|
margin-left: 5px;
|
|
}
|
|
.row{
|
|
margin: 3px;
|
|
}
|
|
.crossed{
|
|
text-decoration: line-through;
|
|
}
|
|
|
|
.return{
|
|
margin: 1px;
|
|
}
|
|
</style>
|
|
<script src="{% static 'mfa/js/qrious.min.js' %}" type="text/javascript"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function checkTokenLeft() {
|
|
$.ajax({"url":"{% url 'get_recovery_token_left' %}", dataType:"JSON",
|
|
success:function (data) {
|
|
tokenLeft = data.left
|
|
let html
|
|
if (tokenLeft == 0) {
|
|
html = "<h6>You don't have any backup code left, please generate new ones !</h6>"
|
|
|
|
}
|
|
else {
|
|
html = "<p>You still have "+tokenLeft+" backup code left."
|
|
}
|
|
document.getElementById('tokens').innerHTML = html
|
|
}})
|
|
});
|
|
function confirmRegenerateTokens() {
|
|
htmlModal = "<h6>Caution! you can only note these token now, else you will need to generate new ones.</h6><button onclick='regenerateTokens()' class='btn btn-success'>Regenerate</button>"
|
|
$("#modal-title").html("Are you sure you want to regenerate your recovery tokens?")
|
|
$("#modal-body").html(htmlModal)
|
|
$("#popUpModal").modal('show')
|
|
}
|
|
function regenerateTokens() {
|
|
$.ajax({
|
|
"url":"{% url 'regen_recovery_tokens' %}", dataType:"JSON",
|
|
success:function (data) {
|
|
let htmlkey="";
|
|
for (let i = 0; i < data.keys.length; i++) {
|
|
htmlkey +="<pre>" +data.keys[i] + "</pre>"
|
|
}
|
|
document.getElementById('tokens').innerHTML = htmlkey
|
|
$("#popUpModal").modal('hide')
|
|
}
|
|
})
|
|
}
|
|
</script>
|
|
{% endblock %}
|
|
{% block content %}
|
|
<br/>
|
|
<br/>
|
|
<div class="container d-flex justify-content-center">
|
|
<div class="col-md-6 col-md-offset-3" id="two-factor-steps">
|
|
|
|
<div class="row">
|
|
|
|
<h4>Token List</h4>
|
|
|
|
</div>
|
|
|
|
<div class="tokenrow" id="tokens">
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-md-6" style="padding-left: 0px">
|
|
|
|
<button onclick="confirmRegenerateTokens()" class="btn btn-success">Regenarate tokens</button>
|
|
|
|
</div>
|
|
<div class="col-md-6" align="right" style="padding-right: 30px">
|
|
|
|
<a href="{{redirect_html}}" class="btn btn-default btn-secondary" role="button"> {{reg_success_msg}}</a>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% include "modal.html" %}
|
|
{% endblock %}
|