Initial Import

This commit is contained in:
Mohamed El-Kalioby
2019-01-18 10:18:10 +03:00
parent 5665e46a18
commit 800f60ff53
40 changed files with 1749 additions and 0 deletions

View File

@@ -0,0 +1,123 @@
{% extends "login_base.html" %}
{% block head %}
<script type="application/javascript">
function checkFlag() {
if ($("#agree").is(":checked"))
return true;
else
alert("Please agree to the statement first");
return false;
}
function checkTrusted() {
$.ajax({
url:"{% url 'td_checkTrusted' %}",
success:function (data) {
if (data == "OK")
window.location.href="{% url 'td_securedevice' %}";
else
setTimeout('checkTrusted()',2000)
}
})
}
$(document).ready(checkTrusted())
</script>
{% endblock %}
{% block form %}
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-xs-12 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<strong> Add Trusted Device</strong>
</div>
<div class="panel-body">
{% if success %}
<div class="alert alert-warning">
Please check your PC window, to continue the process.
</div>
{% elif added %}
<div class="alert alert-success">
Your device is now trusted, please try to <a href="{% url 'login' %}"> login</a>
</div>
{% else %}
<div class="alert alert-warning">Please make sure you are not in private (incognito) mode <i class="fal fa-user-secret"></i></div>
<FORM METHOD="POST" ACTION="{% url 'add_td' %}" Id="formLogin" onSubmit="return checkFlag()" name="FrontPage_Form1">
{% csrf_token %}
{% if invalid %}
<div class="alert alert-danger">
{{ invalid }}
</div>
{% endif %}
{% if quota %}
<div class="alert alert-warning">
{{ quota }}
</div>
{% endif %}
<fieldset>
<div class="row">
<div class="col-sm-12 col-md-12">
{# <img class="profile-img" src="{{ STATIC_URL }}img/users.png" alt="">#}
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-12">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="glyphicon glyphicon-user"></i>
</span>
<input class="form-control" id="username" size="30" MaxLength="30" placeholder="Username" name="username" value="{{ username }}" type="text" autofocus autocomplete="on">
</div>
</div>
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-key"></i>
</span>
<input class="form-control" placeholder="e.g GAK-Y2M" id='key' style="text-transform: uppercase" name="key" type="text" size="9" MaxLength="9" value="{{ key }}">
</div>
</div>
<div class="form-group">
<span class="input-group">
<input id='agree' name="agree" type="checkbox"><span style="color: red"> I confirm that this device is mine and it is only used by me.</span>
</div>
{% comment %}
<div class="form-group">
<div class="input-group">
<span class="input-group-addon">
<select size="1" name="Institution_Code" style="font-size: 10pt; font-family: Calibri; height: 34px;width: 230px">
{% for ins in institutes %}
<option value="{{ ins.institution_code }}">{{ ins.alias }}</option>
{% endfor %}
</select>
</span>
</div>
</div>
{% endcomment %}
<div class="form-group">
<input type="submit" class="btn btn-lg btn-success btn-block" value="Trust Device">
</div>
</div>
</div>
</fieldset>
</form>
{% endif %}
</div>
<div class="panel-footer ">
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,27 @@
{% extends "login_base.html" %}
{% block head %}
{% endblock %}
{% block form %}
<div class="row">
<div class="col-sm-10 col-sm-offset-1 col-xs-12 col-md-10 col-md-offset-1 col-lg-8 col-lg-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<strong> Add Trusted Device</strong>
</div>
<div class="panel-body">
<div class="alert alert-success">
Your device is now trusted, please try to <a href="{{ HOST }}{{ BASE_URL }}accounts/login/"> login</a>
</div>
</div>
<div class="panel-footer ">
</div>
</div>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,4 @@
<p>Dear {{ request.user.last_name }}, {{ request.user.first_name }}</p>
<p>You requested the link to add a new trusted device, please follow the link below<br/>
<a href="{{ HOST }}{% url 'mfa_add_new_trusted_device' %}">{{ HOST }}{% url 'mfa_add_new_trusted_device' %}</a>
</p>

View File

@@ -0,0 +1,100 @@
{% extends "base.html" %}
{% block head %}
<style>
#two-factor-steps {
border: 1px solid #ccc;
border-radius: 3px;
padding: 15px;
}
.row{
margin: 0px;
}
</style>
<script type="text/javascript">
function sendEmail() {
$("#modal-title").html("Send Link")
$("#modal-body").html("Sending Email, Please wait....");
$("#popUpModal").modal();
$.ajax({
"url":"{% url 'td_sendemail' %}",
success:function (data) {
alert(data);
$("#popUpModal").modal('toggle')
}
})
}
function failedMFA() {
$("#modal-body").html("<div class='alert alert-danger'>Failed to validate you, please <a href='javascript:void(0)' onclick='getUserAgent()'>try again</a></div>")
}
function checkMFA() {
recheck_mfa(trustDevice,failedMFA,true)
}
function trustDevice() {
$.ajax(
{
"url":"{% url 'td_trust_device' %}",
success: function (data) {
if (data == "OK")
{
alert("Your are done, your device should show final confirmation")
window.location.href="{% url 'mfa_home' %}"
}
}
}
)
}
function getUserAgent() {
$.ajax({
"url":"{% url 'td_get_useragent' %}",success: function(data)
{
if (data == "")
setTimeout('getUserAgent()',5000)
else
{
$("#modal-title").html("Confirm Trusted Device")
$("#actionBtn").remove();
$("#modal-footer").prepend("<button id='actionBtn' class='btn btn-success' onclick='checkMFA()'>Trust Device</button>")
$("#modal-body").html(data)
$("#popUpModal").modal()
}
}
})
}
$(document).ready(getUserAgent())
</script>
{% endblock %}
{% block content %}
<div class="container">
<div class="col-md-6 col-md-offset-3" id="two-factor-steps">
<div class="row" align="center">
<h4>Add Trusted Device</h4>
</div>
<div class="row" >
{% if not_allowed %}
<div class="alert alert-danger">You can't add any more devices, you need to remove previously trusted devices first.</div>
{% else %}
<p style="color: green">Allow access from mobile phone and tables.</p>
<h5>Steps:</h5>
<ol>
<li>Using your mobile/table, open Chrome/Firefox.</li>
<li>Go to <b>{{ HOST }}{{ BASE_URL }}devices/add</b>&nbsp;&nbsp;<a href="javascript:void(0)" onclick="sendEmail()" title="Send to my email"><i class="fas fa-paper-plane"></i></a></li>
<li>Enter your username & following 6 digits<br/>
<span style="font-size: 16px;font-weight: bold; margin-left: 50px">{{ key|slice:":3" }} - {{ key|slice:"3:" }}</span>
</li>
<li>This window will ask to confirm the device.</li>
</ol>
{% endif %}
</div>
</div>
</div>
{% include "modal.html" %}
{% include 'mfa_check.html' %}
{% endblock %}

View File

@@ -0,0 +1,14 @@
<table>
<tr>
<th>Browser: </th>
<td>{{ ua.browser.family }}</td>
</tr>
<tr>
<th>Version: </th>
<td>{{ ua.browser.version_string }}</td>
</tr>
<tr>
<th>Device: </th>
<td>{{ ua.device.brand }} / {{ ua.device.model }}</td>
</tr>
</table>