diff --git a/src/pretix/presale/forms/customer.py b/src/pretix/presale/forms/customer.py index 2b6e4f835..acddff83b 100644 --- a/src/pretix/presale/forms/customer.py +++ b/src/pretix/presale/forms/customer.py @@ -44,6 +44,7 @@ from pretix.base.forms.questions import ( from pretix.base.i18n import get_language_without_region from pretix.base.models import Customer from pretix.helpers.http import get_client_ip +from pretix.multidomain.urlreverse import build_absolute_uri class TokenGenerator(PasswordResetTokenGenerator): @@ -68,16 +69,24 @@ class AuthenticationForm(forms.Form): 'invalid_login': _( "We have not found an account with this email address and password." ), + 'invalid_login_email': _('Please verify that you entered the correct email addess.'), + 'invalid_login_password': _('Please enter the correct password.'), 'inactive': _("This account is disabled."), 'unverified': _("You have not yet activated your account and set a password. Please click the link in the " - "email we sent you. Click \"Reset password\" to receive a new email in case you cannot find " - "it again."), + "email we sent you. In case you cannot find it, click \"Forgot your password?\" to receive " + "a new email."), } def __init__(self, request=None, *args, **kwargs): self.request = request self.customer_cache = None super().__init__(*args, **kwargs) + self.fields['password'].help_text = "{}".format( + build_absolute_uri(False, 'presale:organizer.customer.resetpw', kwargs={ + 'organizer': request.organizer.slug, + }), + _('Forgot your password?') + ) def clean(self): email = self.cleaned_data.get('email') @@ -94,6 +103,8 @@ class AuthenticationForm(forms.Form): if u.check_password(password): self.customer_cache = u if self.customer_cache is None: + self.add_error("email", self.error_messages['invalid_login_email']) + self.add_error("password", self.error_messages['invalid_login_password']) raise forms.ValidationError( self.error_messages['invalid_login'], code='invalid_login', @@ -110,15 +121,9 @@ class AuthenticationForm(forms.Form): def confirm_login_allowed(self, user): if not user.is_active: - raise forms.ValidationError( - self.error_messages['inactive'], - code='inactive', - ) - if not user.is_verified: - raise forms.ValidationError( - self.error_messages['unverified'], - code='unverified', - ) + self.add_error("email", self.error_messages['inactive']) + elif not user.is_verified: + self.add_error("password", self.error_messages['unverified']) def get_customer(self): return self.customer_cache diff --git a/src/pretix/presale/templates/pretixpresale/event/checkout_customer.html b/src/pretix/presale/templates/pretixpresale/event/checkout_customer.html index df8388494..28992c4d1 100644 --- a/src/pretix/presale/templates/pretixpresale/event/checkout_customer.html +++ b/src/pretix/presale/templates/pretixpresale/event/checkout_customer.html @@ -48,15 +48,6 @@

{% if request.organizer.settings.customer_accounts_native %} {% bootstrap_form login_form layout="checkout" %} -
-
- - {% trans "Reset password" %} - -
-
{% endif %}
diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_info.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_info.html index 090baf9d1..990480128 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_info.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_info.html @@ -6,19 +6,26 @@ {% block title %}{% trans "Account information" %}{% endblock %} {% block content %}
-
-

- {% blocktrans trimmed %} - Update your account information - {% endblocktrans %} -

-
+
+ {% csrf_token %} - {% bootstrap_form form %} -
- +
+
+

+ {% trans "Update your account information" %} +

+
+
+ {% bootstrap_form form layout="checkout" %} +
+
+
+
+ +
+
diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_login.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_login.html index e9fc07fa2..4fd649ad0 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_login.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_login.html @@ -7,48 +7,70 @@ {% block content %}
-

+ {% if request.organizer.settings.customer_accounts_native %} +
+ {% csrf_token %} +
+
+

+ {% blocktrans trimmed with org=request.organizer.name %} + Sign in to your account at {{ org }} + {% endblocktrans %} +

+
+
+ {% bootstrap_form form layout="checkout" %} + +
+ +
+ +
+
+
+ +
+
+
+ {% else %} +

{% blocktrans trimmed with org=request.organizer.name %} Sign in to your account at {{ org }} {% endblocktrans %} -

-
- {% csrf_token %} - {% if request.organizer.settings.customer_accounts_native %} - {% bootstrap_form form %} -
- -
- {% endif %} + + {% endif %} + + {% if providers %} +
+ {% endif %}

 

diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_password.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_password.html index 4eb6eb868..b4c94d9b7 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_password.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_password.html @@ -7,18 +7,25 @@ {% block content %}
-

- {% blocktrans trimmed %} - Set a new password for your account - {% endblocktrans %} -

-
+ {% csrf_token %} - {% bootstrap_form form %} -
- +
+
+

+ {% trans "Set a new password for your account" %} +

+
+
+ {% bootstrap_form form layout="checkout" %} +
+
+
+
+ +
+
diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_registration.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_registration.html index efaf01621..b6d9d9503 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_registration.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_registration.html @@ -1,28 +1,54 @@ {% extends "pretixpresale/organizers/base.html" %} {% load i18n %} +{% load icon %} {% load eventurl %} {% load urlreplace %} {% load bootstrap3 %} {% block title %}{% trans "Registration" %}{% endblock %} {% block content %}
-
-

- {% blocktrans trimmed with org=request.organizer.name %} - Create a new account at {{ org }} - {% endblocktrans %} -

-
+
+ {% csrf_token %} - {% bootstrap_form form %} -
- +
+
+

+ {% blocktrans trimmed with org=request.organizer.name %} + Create a new account at {{ org }} + {% endblocktrans %} +

+
+
+ {% bootstrap_form form layout="checkout" %} +
+
+
+ +
+ +
+
+
+ - - {% trans "Log in to an existing account" %} -
diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_resetpw.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_resetpw.html index 02a705cce..8a8a57292 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_resetpw.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_resetpw.html @@ -1,5 +1,6 @@ {% extends "pretixpresale/organizers/base.html" %} {% load i18n %} +{% load icon %} {% load eventurl %} {% load urlreplace %} {% load bootstrap3 %} @@ -7,18 +8,44 @@ {% block content %}
-

- {% blocktrans trimmed %} - Password reset - {% endblocktrans %} -

-
+ {% csrf_token %} - {% bootstrap_form form %} -
- +
+
+

+ {% trans "Request a new password" %} +

+
+
+ {% bootstrap_form form layout="checkout" %} + +
+ +
+ +
+
+
+ +
diff --git a/src/pretix/presale/templates/pretixpresale/organizers/customer_setpassword.html b/src/pretix/presale/templates/pretixpresale/organizers/customer_setpassword.html index 4eb6eb868..f515c559c 100644 --- a/src/pretix/presale/templates/pretixpresale/organizers/customer_setpassword.html +++ b/src/pretix/presale/templates/pretixpresale/organizers/customer_setpassword.html @@ -7,18 +7,25 @@ {% block content %}
-

- {% blocktrans trimmed %} - Set a new password for your account - {% endblocktrans %} -

-
+ {% csrf_token %} - {% bootstrap_form form %} -
- +
+
+

+ {% trans "Set a new password for your account" %} +

+
+
+ {% bootstrap_form form layout="checkout" %} +
+
+
+
+ +
+
diff --git a/src/pretix/presale/views/customer.py b/src/pretix/presale/views/customer.py index 5d8fd42ab..a2aa3ff07 100644 --- a/src/pretix/presale/views/customer.py +++ b/src/pretix/presale/views/customer.py @@ -122,7 +122,7 @@ class LoginView(RedirectBackMixin, FormView): def get_context_data(self, **kwargs): return super().get_context_data( **kwargs, - providers=self.request.organizer.sso_providers.all() + providers=self.request.organizer.sso_providers.filter(is_active=True) ) def get_form_kwargs(self): diff --git a/src/tests/presale/test_customer.py b/src/tests/presale/test_customer.py index 7e4329b69..01474734f 100644 --- a/src/tests/presale/test_customer.py +++ b/src/tests/presale/test_customer.py @@ -239,7 +239,7 @@ def test_org_login_not_verified(env, client, mocker): 'password': 'foo', }) assert r.status_code == 200 - assert b'alert-danger' in r.content + assert b'form-group has-error' in r.content customer_signed_in.send.assert_not_called() @@ -258,7 +258,7 @@ def test_org_login_not_active(env, client, mocker): 'password': 'foo', }) assert r.status_code == 200 - assert b'alert-danger' in r.content + assert b'form-group has-error' in r.content customer_signed_in.send.assert_not_called()