Added javascript cookie check, if blocked, login in new tab

This commit is contained in:
David Taylor
2016-10-08 22:55:27 +01:00
parent 879ecd1f6d
commit 5949ff74ec
5 changed files with 34 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
<body>
{% include "analytics.html" %}
<div class="embed_container" style="border: 5px solid #e9e9e9;">
<div class="embed_container">
<div class="container-fluid">
{% block content %}
{% endblock %}

View File

@@ -3,6 +3,18 @@
{% block title %}Login{% endblock %}
{% block js %}
<script>
$(document).ready(function(){
console.log("Cookies Enabled: " + navigator.cookieEnabled)
if(!navigator.cookieEnabled){
$('#loginForm').prop("target", "_blank");
$('#cookieWarning').removeClass('hidden');
}
});
</script>
{% endblock %}
{% block content %}
<div class="text-center">
<h1>R<small>ig</small> I<small>nformation</small> G<small>athering</small> S<small>ystem</small></h1>
@@ -10,9 +22,11 @@
{% include 'form_errors.html' %}
<div class="col-sm-6 col-sm-offset-3 col-lg-4 col-lg-offset-4">
<form action="" method="post" role="form" target="_self">{% csrf_token %}
<form id="loginForm" action="" method="post" role="form" target="_self">{% csrf_token %}
<div class="form-group">
<label for="id_username">{{ form.username.label }}</label>
{% render_field form.username class+="form-control" placeholder=form.username.label %}
@@ -21,9 +35,14 @@
<label for="{{ form.password.id_for_label }}">{{ form.password.label }}</label>
{% render_field form.password class+="form-control" placeholder=form.password.label %}
</div>
<input type="submit" value="Login" class="btn btn-primary pull-right"/>
<div class="text-right">
<span id="cookieWarning" class="text-warning hidden">
Login will happen in new tab (cookies blocked)
</span>
<input type="submit" value="Login" class="btn btn-primary"/>
</div>
<input type="hidden" name="next" value="{{ next }}"/>
</form>
</div>