Changeset - 9408a5c7bf65
[Not reviewed]
0 2 0
Ben Sturmfels (bsturmfels) - 10 months ago 2023-06-07 12:08:20
ben@sturm.com.au
Avoid showing the test@example.com email address on the password reset page

Also updated login form to prompt you to use your username if you fail to login
with what looks like an email address.
2 files changed with 23 insertions and 0 deletions:
0 comments (0 inline, 0 general)
pinaxcon/settings.py
Show inline comments
...
 
@@ -631,3 +631,6 @@ if not DEBUG:
 
        'security.W004',
 
        # Don't want to preload HSTS at this stage.
 
        'security.W021']
 

	
 

	
 
THEME_CONTACT_EMAIL = CONFERENCE_EMAIL
pinaxcon/urls.py
Show inline comments
 
from account.forms import LoginUsernameForm
 
from account.views import LoginView
 
import debug_toolbar
 
from django.conf import settings
 
from django.conf.urls.static import static
 
from django.core.exceptions import ValidationError
 
from django.views.generic import RedirectView
 
from django.views.generic import TemplateView
 
from django.urls import include, path
...
 
@@ -11,6 +14,22 @@ from django.contrib import admin
 
import symposion.views
 

	
 

	
 
class CustomLoginForm(LoginUsernameForm):
 
    def clean(self):
 
        # To use account.forms.LoginEmailForm, we need to enforce unique
 
        # emails. Since we probably already have duplicate emails in the system,
 
        # we'll defer that to next year.
 
        try:
 
            super().clean()
 
        except ValidationError as e:
 
            if '@' in self.cleaned_data['username']:
 
                raise ValidationError(
 
                    f'{e.message} Please login with your username, rather than your email.'
 
                )
 
            else:
 
                raise
 

	
 

	
 
urlpatterns = [
 
    # Trialling homepage via flatpages.
 
    # path('', TemplateView.as_view(template_name="homepage.html")),
...
 
@@ -27,6 +46,7 @@ urlpatterns = [
 
    path("teams/", include("symposion.teams.urls")),
 
    path('raffle/', include("pinaxcon.raffle.urls")),
 

	
 
    path("account/login/", LoginView.as_view(form_class=CustomLoginForm, template_name='account/login.html'), name="account_login"),
 
    path("account/", include("account.urls")),
 

	
 
    # Required by registrasion
0 comments (0 inline, 0 general)