Skip to content

Commit

Permalink
Assorted preauth bits missed from yesterday
Browse files Browse the repository at this point in the history
Register form email field renamed, backgrounds and prevent authenticated users visiting preauth pages.
  • Loading branch information
wjdp committed May 29, 2016
1 parent e687892 commit 3afb083
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ xSACdb instances. This project will soon adhere to [Semantic Versioning](http://

### Changed
- Upgraded the UI framework from Bootstrap v2 to v4, includes *significant UI improvements* especially on mobile.
- Redesigned, mobile friendly login and register pages.
- Because we have Redis, cache backend has switched from in-memory to Redis.


## [0.1.1] - Unreleased

### Changed
Expand Down
50 changes: 37 additions & 13 deletions src/static_global/sass/_xsd-preauth.sass
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,45 @@
// Pages excluded from padding-top
padding-top: 0

background: mix($brand-primary, black)
// Don't need persistent scroll bar on preauth
overflow-y: auto

.xsd-application-container
padding: 0
color: white

// GENERICS
.xsd-preauth-bg
position: fixed
top: -2%
left: -2%
height: 104%
width: 104%
z-index: -100

background-color: mix($brand-primary, black)
background-image: url('/static/images/login_backgrounds/5.jpg')
background-blend-mode: color-dodge
background-repeat: no-repeat
background-size: cover
background-position: 25%

.xsd-preauth-big-icon
display: block
font-size: 50vw
text-align: center
opacity: 0.4

.xsd-preauth-content
width: 90%
width: 100%
margin: 0 auto

max-width: 800px

padding-bottom: 2rem
padding: 5vw
background: rgba(255,255,255,0.7)
color: #333

.xsd-preauth-logo
margin: 0 auto
Expand Down Expand Up @@ -70,11 +88,10 @@
right: 0
left: inherit

background: white
border-top: 6px solid $brand-primary
color: #111
padding: 2rem

background: rgba(255, 255, 255, 0.9)
border-top: 6px solid $brand-primary

.xsd-preauth-message
text-align: center

Expand All @@ -95,13 +112,12 @@
padding: 0.5em
background: $brand-danger
font-weight: bold
color: white


.xsd-preauth-form__controls
.btn
width: 100%
.btn-secondary-outline
opacity: 0.5

// SPECIFICS
Expand All @@ -115,6 +131,9 @@
min-width: 400px
margin: 0 auto

.btn
box-shadow: 0px 2px 1px rgba(0,0,0,0.05)

img
// Facebook logo
height: 1.5em
Expand Down Expand Up @@ -148,7 +167,11 @@
@include media-breakpoint-up(md)
// Hide on medium and up
display: none


a
color: white
opacity: 0.7

.xsd-preauth-login__alternate__email, .xsd-preauth-login__alternate__register
@include make-col
@include make-col-span(6)
Expand All @@ -159,9 +182,6 @@ $email-entry-time: 0.33s
$email-exit-time: 0.22s

@include media-breakpoint-down(sm)
a
color: #ccc

.xsd-preauth-content--login
display: none

Expand Down Expand Up @@ -191,6 +211,10 @@ $email-exit-time: 0.22s
transform: translateY(0)
transition: transform $email-entry-time cubic-bezier(0,0,0.3,1) // Slow entry

.xsd-preauth-form__controls
.btn-secondary-outline
opacity: 0.5

// Makes the page black
.xsd-preauth-blur
position: fixed
Expand Down
4 changes: 3 additions & 1 deletion src/static_global/sass/build.sass
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
@import "variables"

// Library
@import "bourbon/app/assets/stylesheets/bourbon"

@import "tether/src/css/tether.sass"
@import "tether/src/css/tether-theme-basic.sass"
@import "tether/src/css/tether-theme-basic.sass"
Expand Down Expand Up @@ -33,4 +35,4 @@ $fa-font-path: "/static/font-awesome/fonts"

@import "members-table"

$t: 7332222222222222442222553533
$t: 733255533222332233333555533
9 changes: 9 additions & 0 deletions src/xSACdb/roles/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,12 @@ def is_allowed(self,user):
class RequireTrusted(RequireGroup):
def is_allowed(self,user):
return is_trusted(user)

from django.http import HttpResponseRedirect

class RequirePreauth(object):
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated():
return HttpResponseRedirect('/')
else:
return super(RequirePreauth, self).dispatch(request, *args, **kwargs)
2 changes: 1 addition & 1 deletion src/xsd_auth/templates/account/password_reset_done.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
{% endif %}
<h2>Forgotten password</h2>
<p>We have sent you an email with a link to reset your password.</p>
<p><a href="{% url 'xsd_frontend:login' %}">Back to login &hellip;</a></p>
<p><a href="{% url 'xsd_frontend:login' %}">Back to login&hellip;</a></p>
</div>
{% endblock %}
8 changes: 4 additions & 4 deletions src/xsd_frontend/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class UserRegisterForm(forms.Form):
email = forms.EmailField()
password = forms.CharField(widget=forms.PasswordInput)

def clean_email_address(self):
def clean_email(self):
form_data = self.cleaned_data
if 'email' in form_data and User.objects.filter(email=form_data['email']):
self.add_error('email_address', 'An account on this site is already using that email address')
return form_data['email']
self.add_error('email', 'An account on this site is already using that email address')
return form_data.get('email', None)

def clean_password(self):
form_data = self.cleaned_data
if 'password' in form_data and len(form_data['password']) < 8:
self.add_error('password', 'Password must be at least 8 characters')
return form_data['password']
return form_data.get('password', None)

2 changes: 1 addition & 1 deletion src/xsd_frontend/templates/preauth/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{% block body_class %}xsd-preauth{% endblock %}

{% block content %}
<div class="xsd-preauth-bg"></div>
<h1 class="xsd-preauth-logo">
<a href="{% url 'xsd_frontend:login' %}">
<img src="{% static 'images/logo.png' %}" alt="{{ l10n_club.name }}" />
Expand Down Expand Up @@ -31,4 +32,3 @@ <h1 class="xsd-preauth-logo">

{% endblock %}
{% endblock %}
eas
6 changes: 2 additions & 4 deletions src/xsd_frontend/templates/preauth/login.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{% extends 'preauth/base.html' %}
{% load staticfiles %}
{% load socialaccount %}

{% block body_class %}xsd-preauth xsd-preauth--login{% endblock %}

Expand All @@ -19,12 +20,9 @@ <h2>Sign in</h2>
</div>
<div class="xsd-preauth-content__onboard">
<h2>New Here?</h2>
<p>This is the club database for {{ l10n_club.name }}, to create an account click on the <a href="#">Facebook login button</a>, alternatively you can use your <a href="{% url 'xsd_frontend:register' %}">email address</a>.</p>
<p>This is the club database for {{ l10n_club.name }}, to create an account click on the <a href="{% provider_login_url "facebook" %}">Facebook login button</a>, alternatively you can use your <a href="{% url 'xsd_frontend:register' %}">email address</a>.</p>
</div>
</div>

</div>

<div class="xsd-preauth-blur {% if form.errors %}xsd-preauth-blur--visible{% endif %}"></div>

{% endblock %}
6 changes: 3 additions & 3 deletions src/xsd_frontend/templates/preauth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{% block preauth_content %}
<div class="xsd-preauth-content">

<p>You can create an account via <a href="#">Facebook</a> or your email address.</p>
<p>You can create an account via Facebook or your email address.</p>

<div class="xsd-preauth-register-facebook">
{% include 'preauth/facebook_button.html' %}
Expand Down Expand Up @@ -37,13 +37,13 @@
</label>

<label>
{{ form.email_address.errors }}
{{ form.email.errors }}
<input type="email"
name="email"
class="form-control"
placeholder="Email"
autocomplete="email"
{% if form.email_address.value %}value="{{ form.email_address.value }}"{% endif %}
{% if form.email.value %}value="{{ form.email.value }}"{% endif %}
required>
</label>

Expand Down
6 changes: 3 additions & 3 deletions src/xsd_frontend/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from models import UpdateRequest

from xSACdb.roles.functions import is_verified, is_trusted
from xSACdb.roles.mixins import RequireTrusted
from xSACdb.roles.mixins import RequireTrusted, RequirePreauth


def dashboard(request):
Expand Down Expand Up @@ -75,7 +75,7 @@ def dashboard(request):
from django.contrib.auth import authenticate
from django.contrib.auth import login

class PreauthLoginView(FormView):
class PreauthLoginView(RequirePreauth, FormView):
template_name = 'preauth/login.html'
form_class = LoginForm
success_url = '/'
Expand All @@ -84,7 +84,7 @@ def form_valid(self, form):
login(self.request, form.get_user())
return super(PreauthLoginView, self).form_valid(form)

class PreauthRegisterView(FormView):
class PreauthRegisterView(RequirePreauth, FormView):
template_name = 'preauth/register.html'
form_class = UserRegisterForm
success_url = '/'
Expand Down

0 comments on commit 3afb083

Please sign in to comment.