From 3756923f406033b01be6fb67d96bc188c09c1c53 Mon Sep 17 00:00:00 2001 From: Henrik Levkowetz Date: Thu, 27 Sep 2018 12:52:40 +0000 Subject: [PATCH] Added username validation to the change username form, to avoid database key collision exceptions. Instead give a message to contact the secretariat to resolve the situation. - Legacy-Id: 15490 --- ietf/ietfauth/forms.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ietf/ietfauth/forms.py b/ietf/ietfauth/forms.py index ab42fd144..65bad7dfe 100644 --- a/ietf/ietfauth/forms.py +++ b/ietf/ietfauth/forms.py @@ -256,3 +256,9 @@ class ChangeUsernameForm(forms.Form): if not self.user.check_password(password): raise ValidationError('Invalid password') return password + + def clean_username(self): + username = self.cleaned_data['username'] + if User.objects.filter(username=username).exists(): + raise ValidationError("A login with that username already exists. Please contact the secretariat to get this resolved.") + return username