@ -10,7 +10,7 @@ from django.conf import settings | |||||
class LoginTestCase(TestCase): | class LoginTestCase(TestCase): | ||||
def test_it_sends_link(self): | def test_it_sends_link(self): | ||||
form = {"identity": "[email protected]"} | |||||
form = {"email": "[email protected]"} | |||||
r = self.client.post("/accounts/login/", form) | r = self.client.post("/accounts/login/", form) | ||||
assert r.status_code == 302 | assert r.status_code == 302 | ||||
@ -32,10 +32,9 @@ class LoginTestCase(TestCase): | |||||
self.client.get("/accounts/login/") | self.client.get("/accounts/login/") | ||||
assert "bad_link" not in self.client.session | assert "bad_link" not in self.client.session | ||||
@override_settings(REGISTRATION_OPEN=False) | @override_settings(REGISTRATION_OPEN=False) | ||||
def test_it_obeys_registration_open(self): | def test_it_obeys_registration_open(self): | ||||
form = {"identity": "[email protected]"} | |||||
form = {"email": "[email protected]"} | |||||
r = self.client.post("/accounts/login/", form) | r = self.client.post("/accounts/login/", form) | ||||
assert r.status_code == 200 | assert r.status_code == 200 | ||||
@ -45,7 +44,7 @@ class LoginTestCase(TestCase): | |||||
alice = User(username="alice", email="[email protected]") | alice = User(username="alice", email="[email protected]") | ||||
alice.save() | alice.save() | ||||
form = {"identity": "[email protected]"} | |||||
form = {"email": "[email protected]"} | |||||
r = self.client.post("/accounts/login/", form) | r = self.client.post("/accounts/login/", form) | ||||
assert r.status_code == 302 | assert r.status_code == 302 | ||||
@ -0,0 +1,74 @@ | |||||
.page-login h1 { | |||||
text-align: center; | |||||
margin: 40px 0; | |||||
} | |||||
.page-login .alert { | |||||
margin-bottom: 40px; | |||||
} | |||||
.page-login form p { | |||||
margin-bottom: 20px; | |||||
text-align: center; | |||||
} | |||||
.page-login form input { | |||||
margin-bottom: 20px; | |||||
} | |||||
@media (min-width: 768px) { | |||||
#magic-link-form { | |||||
margin-right: 50px; | |||||
} | |||||
#login-form { | |||||
margin-left: 50px; | |||||
} | |||||
} | |||||
#link-instruction { | |||||
color: #999; | |||||
font-style: italic; | |||||
padding: 12px 16px; | |||||
} | |||||
#login-sep { | |||||
background:#ddd; | |||||
position: absolute; | |||||
top: 10%; | |||||
right: -1px; | |||||
height: 80%; | |||||
width: 1px; | |||||
} | |||||
#login-sep div { | |||||
position: absolute; | |||||
top: 40%; | |||||
width: 40px; | |||||
left: -20px; | |||||
text-align: center; | |||||
background: #fff; | |||||
font-style: italic; | |||||
color: #666; | |||||
font-size: 12px; | |||||
padding: 8px 0; | |||||
} | |||||
#xs-login-sep { | |||||
text-align: center; | |||||
margin: 40px; | |||||
font-style: italic; | |||||
color: #666; | |||||
font-size: 12px; | |||||
height: 1px; | |||||
background: #ddd; | |||||
} | |||||
#xs-login-sep div { | |||||
position: relative; | |||||
margin: 0 auto; | |||||
width: 30px; | |||||
top: -9px; | |||||
background: #fff; | |||||
} | |||||
@ -3,77 +3,82 @@ | |||||
{% block content %} | {% block content %} | ||||
<div class="row"> | <div class="row"> | ||||
<div class="col-sm-6 col-sm-offset-3"> | |||||
<div class="hc-dialog"> | |||||
{% if bad_link %} | |||||
<h1>Incorrect Login Link</h1> | |||||
<div class="dialog-body"> | |||||
<p>The login link you just used is either incorrect or expired.</p> | |||||
<p>Please use the form below to request a fresh login link:</p> | |||||
</div> | |||||
{% else %} | |||||
<h1>{% site_name %}</h1> | |||||
<div class="dialog-body"> | |||||
<p> | |||||
{% if show_password %} | |||||
Please enter your email address and password. | |||||
{% else %} | |||||
Please enter your email address. | |||||
Next, we'll send you an email with log-in instructions! | |||||
{% endif %} | |||||
</p> | |||||
</div> | |||||
{% endif %} | |||||
<div class="col-xs-10 col-xs-offset-1 col-sm-12 col-sm-offset-0 col-lg-8 col-lg-offset-2"> | |||||
{% if bad_credentials %} | |||||
<p class="alert alert-danger">Incorrect email or password.</p> | |||||
{% endif %} | |||||
<h1>Sign In to {% site_name %}</h1> | |||||
{% if bad_link %} | |||||
<div class="alert alert-warning"> | |||||
<p>The login link you just used is either incorrect or expired.</p> | |||||
<p>Please use the form below to request a fresh login link.</p> | |||||
</div> | |||||
{% endif %} | |||||
<form method="post"> | |||||
{% csrf_token %} | |||||
<div class="row"> | |||||
<div class="col-sm-6"> | |||||
<form id="magic-link-form" method="post"> | |||||
{% csrf_token %} | |||||
<div class="form-group"> | |||||
<div class="input-group input-group-lg"> | |||||
<div class="input-group-addon"> | |||||
<span class="icon-mail"></span> | |||||
</div> | |||||
<input | |||||
type="text" | |||||
class="form-control" | |||||
name="identity" | |||||
value="{{ form.identity.value|default:"" }}" | |||||
placeholder="[email protected]"> | |||||
</div> | |||||
</div> | |||||
{% if magic_form.email.errors %} | |||||
<p class="text-danger">Incorrect email address.</p> | |||||
{% else %} | |||||
<p>Enter your <strong>email address</strong>.</p> | |||||
{% endif %} | |||||
{% if not show_password %} | |||||
<div class="checkbox" id="password-toggle"> | |||||
<label> | |||||
<input type="checkbox"> I want to use a password | |||||
</label> | |||||
</div> | |||||
{% endif %} | |||||
<input | |||||
type="text" | |||||
class="form-control input-lg" | |||||
name="email" | |||||
value="{{ magic_form.email.value|default:"" }}" | |||||
placeholder="[email protected]"> | |||||
<p id="link-instruction"> | |||||
We will email you a magic sign in link. | |||||
</p> | |||||
<button type="submit" class="btn btn-lg btn-primary btn-block"> | |||||
Email Me a Link | |||||
</button> | |||||
</form> | |||||
<div id="login-sep" class="hidden-xs"><div>or</div></div> | |||||
</div> | |||||
<div id="password-block" class="form-group {% if not show_password %} hide {% endif %}"> | |||||
<div class="input-group input-group-lg"> | |||||
<div class="input-group-addon"> | |||||
<span class="icon-dots"></span> | |||||
</div> | |||||
<input | |||||
type="password" | |||||
class="form-control" | |||||
name="password" | |||||
placeholder="password"> | |||||
</div> | |||||
<div class="col-xs-12 visible-xs-block"> | |||||
<div id="xs-login-sep"> | |||||
<div>or</div> | |||||
</div> | </div> | ||||
</div> | |||||
<div class="col-sm-6"> | |||||
<form id="login-form" method="post"> | |||||
{% csrf_token %} | |||||
<input type="hidden" name="action" value="login" /> | |||||
{% if form.non_field_errors %} | |||||
<p class="text-danger">Incorrect email or password.</p> | |||||
{% else %} | |||||
<p> | |||||
Enter your <strong>email address</strong> and <strong>password</strong>. | |||||
</p> | |||||
{% endif %} | |||||
<input | |||||
type="text" | |||||
class="form-control input-lg" | |||||
name="email" | |||||
value="{{ form.email.value|default:"" }}" | |||||
placeholder="[email protected]"> | |||||
<div class="clearfix"> | |||||
<button type="submit" class="btn btn-lg btn-primary pull-right"> | |||||
Log In | |||||
<input | |||||
type="password" | |||||
class="form-control input-lg" | |||||
name="password" | |||||
placeholder="your password"> | |||||
<button type="submit" class="btn btn-lg btn-primary btn-block"> | |||||
Sign In | |||||
</button> | </button> | ||||
</div> | |||||
</form> | |||||
</form> | |||||
</div> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
@ -82,6 +87,7 @@ | |||||
{% block scripts %} | {% block scripts %} | ||||
{% compress js %} | {% compress js %} | ||||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script> | <script src="{% static 'js/jquery-2.1.4.min.js' %}"></script> | ||||
<script src="{% static 'js/bootstrap.min.js' %}"></script> | |||||
<script src="{% static 'js/login.js' %}"></script> | <script src="{% static 'js/login.js' %}"></script> | ||||
{% endcompress %} | {% endcompress %} | ||||
{% endblock %} | {% endblock %} |