diff --git a/hc/accounts/urls.py b/hc/accounts/urls.py index 2c4d6d0c..11759edc 100644 --- a/hc/accounts/urls.py +++ b/hc/accounts/urls.py @@ -3,8 +3,8 @@ from django.conf.urls import url from hc.accounts import views urlpatterns = [ - url(r'^create/$', views.create, name="hc-create-account"), url(r'^login/$', views.login, name="hc-login"), + url(r'^logout/$', views.logout, name="hc-logout"), url(r'^login_link_sent/$', views.login_link_sent, name="hc-login-link-sent"), url(r'^check_token/([\w-]+)/([\w-]+)/$', views.check_token, name="hc-check-token"), ] diff --git a/hc/accounts/views.py b/hc/accounts/views.py index f54bbc26..1fa776cf 100644 --- a/hc/accounts/views.py +++ b/hc/accounts/views.py @@ -1,7 +1,8 @@ import uuid from django.conf import settings -from django.contrib.auth import authenticate, login as auth_login +from django.contrib.auth import authenticate +from django.contrib.auth import login as auth_login, logout as auth_logout from django.contrib.auth.models import User from django.core.mail import send_mail from django.core.urlresolvers import reverse @@ -11,42 +12,23 @@ from django.shortcuts import redirect, render from hc.accounts.forms import EmailForm -def create(request): - assert request.method == "POST" +def _make_user(email): + username = str(uuid.uuid4())[:30] + user = User(username=username, email=email) + user.save() - form = EmailForm(request.POST) - if form.is_valid(): - email = form.cleaned_data["email"] - - num_existing = User.objects.filter(email=email).count() - if num_existing > 0: - # FIXME be more polite about this - return HttpResponseBadRequest() - - username = str(uuid.uuid4())[:30] - temp_password = str(uuid.uuid4()) - - user = User(username=username, email=email) - user.set_password(temp_password) - user.save() - - user = authenticate(username=username, password=temp_password) - user.set_unusable_password() - user.save() - - auth_login(request, user) - return redirect("hc-checks") - - # FIXME do something nicer here - return HttpResponseBadRequest() + return user def login(request): if request.method == 'POST': form = EmailForm(request.POST) if form.is_valid(): - email = form.cleaned_data["email"].lower() - user = User.objects.get(email=email) + email = form.cleaned_data["email"] + try: + user = User.objects.get(email=email) + except User.DoesNotExist: + user = _make_user(email) # We don't want to reset passwords of staff users :-) if user.is_staff: @@ -72,6 +54,11 @@ def login(request): return render(request, "accounts/login.html", ctx) +def logout(request): + auth_logout(request) + return redirect("hc-index") + + def login_link_sent(request): return render(request, "accounts/login_link_sent.html") diff --git a/static/css/pricing.css b/static/css/pricing.css index 859f3992..6f126402 100644 --- a/static/css/pricing.css +++ b/static/css/pricing.css @@ -1,5 +1,3 @@ -@import url("http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"); - .panel-pricing { -moz-transition: all .3s ease; -o-transition: all .3s ease; @@ -11,7 +9,7 @@ .panel-pricing .panel-heading { padding: 20px 10px; } -.panel-pricing .panel-heading .fa { +.panel-pricing .panel-heading .glyphicon { margin-top: 10px; font-size: 58px; } diff --git a/static/css/style.css b/static/css/style.css index 6b5a4eb6..1c3069e3 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -4,7 +4,7 @@ html, body { #pitch { text-align: center; - padding: 3em; + padding: 2em 0 3em 0; } .step-number { @@ -16,7 +16,7 @@ html, body { } #get-started { - margin-top: 3em; + margin-top: 4em; } .glyphicon.up, .glyphicon.new, .glyphicon.down { diff --git a/templates/accounts/login.html b/templates/accounts/login.html index 1de76a1d..d30a9453 100644 --- a/templates/accounts/login.html +++ b/templates/accounts/login.html @@ -4,7 +4,7 @@
-

Hxxx C...

+

Health Checks

Please enter your email address. diff --git a/templates/accounts/login_link_sent.html b/templates/accounts/login_link_sent.html index ebea044a..6ebf213c 100644 --- a/templates/accounts/login_link_sent.html +++ b/templates/accounts/login_link_sent.html @@ -1,5 +1,18 @@ {% extends "base.html" %} {% block content %} -

Login link sent, check your inbox!

+
+
+
+

Login Link Sent!

+
+

+ We've sent you an email with login instructions. + Please check your inbox! +

+ +
+
+
+ {% endblock %} diff --git a/templates/base.html b/templates/base.html index 55927ee8..3ea5e167 100644 --- a/templates/base.html +++ b/templates/base.html @@ -43,7 +43,7 @@