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
This commit is contained in:
parent
b11afc00bf
commit
3756923f40
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue