From patchwork Wed Aug 11 21:37:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Finucane X-Patchwork-Id: 1516043 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=Bd8TZhCN; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GlPBf4czTz9sSs for ; Thu, 12 Aug 2021 08:10:02 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4GlPBf38Z3z306K for ; Thu, 12 Aug 2021 08:10:02 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=Bd8TZhCN; dkim-atps=neutral X-Original-To: patchwork@lists.ozlabs.org Delivered-To: patchwork@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=that.guru (client-ip=136.175.108.195; helo=mail-108-mta195.mxroute.com; envelope-from=stephen@that.guru; receiver=) Authentication-Results: lists.ozlabs.org; dkim=fail reason="key not found in DNS" header.d=that.guru header.i=@that.guru header.a=rsa-sha256 header.s=x header.b=Bd8TZhCN; dkim-atps=neutral Received: from mail-108-mta195.mxroute.com (mail-108-mta195.mxroute.com [136.175.108.195]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4GlPBW08J1z3002 for ; Thu, 12 Aug 2021 08:09:53 +1000 (AEST) Received: from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta195.mxroute.com (ZoneMTA) with ESMTPSA id 17b3743b42f00074ba.002 for (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Wed, 11 Aug 2021 22:09:49 +0000 X-Zone-Loop: 5c13e8e4a785430a74b8958eb41373770c7bfe5f4e3f X-Originating-IP: [149.28.56.236] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=that.guru; s=x; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=qdlRo1V+zd4xAwbdc+JhWEn8B5Ald19SqFHmIiQebMk=; b=Bd8TZhCNWZNzZi6BGcSDAljVx+ wJpuexv7nPjIvCdu34Q7DfEr+chxV+0fnXcucHGKOAEwsWUO88xBthDlRu7Uaz/YZt7490CiBh7w4 U2Oyffksioh4ONFlupCy8GqS7hBjPQa1BiSZ8LDHbDSoP8Q60GJ9d77AEo1FB1o7W+N058IToytpd SDVikZc3sWexCnxsvjiYZOoGm2CLv2H6T4M8J5s9dsSzM/1298mFictrXysbCU7G8fECrlcGUOIgr jhC99In9L5vXgcLrLkubJSKnpPdiIuhk2wJzKlGXBStMYdceHyPiPGST4IdNqwXF+hJCXjUnCySX+ RFnEqhOw==; From: Stephen Finucane To: patchwork@lists.ozlabs.org Subject: [RFC PATCH 19/19] templates: Convert registration page Date: Wed, 11 Aug 2021 22:37:05 +0100 Message-Id: <20210811213705.36293-20-stephen@that.guru> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210811213705.36293-1-stephen@that.guru> References: <20210811213705.36293-1-stephen@that.guru> MIME-Version: 1.0 X-AuthUser: stephen@that.guru X-Zone-Spam-Resolution: no action X-Zone-Spam-Status: No, score=0.9, required=15, tests=[ARC_NA=0, MID_CONTAINS_FROM=1, FROM_HAS_DN=0, RCPT_COUNT_THREE=0, TO_DN_SOME=0, MIME_GOOD=-0.1, FROM_EQ_ENVFROM=0, MIME_TRACE=0, RCVD_COUNT_ZERO=0, NEURAL_SPAM=0] X-BeenThere: patchwork@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Patchwork development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: patchwork-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Patchwork" This is the last of our non submission pages. There's nothing too tricky here except that we no longer use this page for success, instead directing to the index page, and we remove a potential information leak from the registration form that could leak information about registered users without authentication. Next up, the main patch and cover letter list/detail pages. Signed-off-by: Stephen Finucane --- patchwork/forms.py | 7 +- .../templates/patchwork/registration.html | 211 +++++++++--------- patchwork/views/user.py | 15 +- 3 files changed, 120 insertions(+), 113 deletions(-) diff --git patchwork/forms.py patchwork/forms.py index a975db18..b1b68179 100644 --- patchwork/forms.py +++ patchwork/forms.py @@ -32,6 +32,7 @@ class RegistrationForm(forms.Form): User.objects.get(username__iexact=value) except User.DoesNotExist: return self.cleaned_data['username'] + raise forms.ValidationError( 'This username is already taken. Please choose another.' ) @@ -39,12 +40,12 @@ class RegistrationForm(forms.Form): def clean_email(self): value = self.cleaned_data['email'] try: - user = User.objects.get(email__iexact=value) + User.objects.get(email__iexact=value) except User.DoesNotExist: return self.cleaned_data['email'] + raise forms.ValidationError( - 'This email address is already in use ' - 'for the account "%s".\n' % user.username + 'This email address is already in use for another account.' ) def clean(self): diff --git patchwork/templates/patchwork/registration.html patchwork/templates/patchwork/registration.html index 8e2a3511..c9a2a94e 100644 --- patchwork/templates/patchwork/registration.html +++ patchwork/templates/patchwork/registration.html @@ -1,113 +1,112 @@ -{% extends "base.html" %} +{% extends "base2.html" %} {% block title %}Registration{% endblock %} -{% block heading %}Registration{% endblock %} + +{% block navigation %}{% endblock %} {% block body %} -{% if confirmation and not error %} -

- Registration successful! -

-

- A confirmation email has been sent to {{ confirmation.email }}. - You'll need to visit the link provided in that email to confirm your - registration. -

-{% else %} -

By creating a Patchwork account, you can:

-

    -
  • create "bundles" of patches
  • -
  • update the state of your own patches
  • -
-
- {% csrf_token %} - - - - -{% if error %} - - - -{% endif %} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
register
{{ error }}
{{ form.first_name.label_tag }} -{% if form.first_name.errors %} - {{ form.first_name.errors }} -{% endif %} - {{ form.first_name }} -{% if form.first_name.help_text %} -
{{ form.first_name.help_text }}
-{% endif %} -
{{ form.last_name.label_tag }} -{% if form.last_name.errors %} - {{ form.last_name.errors }} -{% endif %} - {{ form.last_name }} -{% if form.last_name.help_text %} -
{{ form.last_name.help_text }}
-{% endif %} -
- Your name is used to identify you on the site -
{{ form.email.label_tag }} -{% if form.email.errors %} - {{ form.email.errors }} +
+
+
+
+
+
+

Create your Patchwork account

+
+{% if form.non_field_errors %} +
+ + {{ form.non_field_errors }} +
{% endif %} - {{ form.email }} -{% if form.email.help_text %} -
{{ form.email.help_text }}
-{% endif %} -
- Patchwork will send a confirmation email to this address -
{{ form.username.label_tag }} -{% if form.username.errors %} - {{ form.username.errors }} -{% endif %} - {{ form.username }} -{% if form.username.help_text %} -
{{ form.username.help_text }}
-{% endif %} -
{{ form.password.label_tag }} -{% if form.password.errors %} - {{ form.password.errors }} -{% endif %} - {{ form.password }} -{% if form.password.help_text %} -
{{ form.password.help_text }}
-{% endif %} -
- -
-
+{% for message in messages %} +{% if message.tags == 'success' %} +
+{% elif message.tags == 'warning' %} +
+{% elif message.tags == 'error' %} +
+{% else %} +
{% endif %} + + {{ message }} +
+{% endfor %} +
+ {% csrf_token %} +
+ +
+ + + + +
+{% for error in form.username.errors %} +

{{ error }}

+{% endfor %} +
+
+ +
+ + + + +
+{% for error in form.email.errors %} +

{{ error }}

+{% endfor %} +
+
+ +
+ + + +
+{% for error in form.first_name.errors %} +

{{ error }}

+{% endfor %} +
+
+ +
+ + + +
+{% for error in form.last_name.errors %} +

{{ error }}

+{% endfor %} +
+
+ +
+ + + + +
+{% for error in form.password.errors %} +

{{ error }}

+{% endfor %} +
+
+ +
+
+
+ Log in +  •  + Forgot Password +
+
+
+
+ + {% endblock %} diff --git patchwork/views/user.py patchwork/views/user.py index 973061b7..8a5bc276 100644 --- patchwork/views/user.py +++ patchwork/views/user.py @@ -81,11 +81,18 @@ def register(request): [confirmation.email] ) except smtplib.SMTPException: - context['confirmation'] = None - context['error'] = ( - 'An error occurred during registration. ' - 'Please try again later' + messages.error( + request, + 'An error occurred while submitting this request. ' + 'Please contact an administrator.' + ) + else: + messages.success( + request, + 'Succesfully signed up. ' + 'Check your email for confirmation.', ) + return HttpResponseRedirect(reverse('project-list')) else: form = RegistrationForm()