fix: 🙏 enforce lowercase usernames for integrity
This commit is contained in:
parent
b50665a62c
commit
58af1acea7
1 changed files with 6 additions and 1 deletions
|
|
@ -62,7 +62,12 @@ class SignupView(FormView):
|
||||||
form_class = UserForm
|
form_class = UserForm
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save()
|
form.instance.username = form.instance.username.lower()
|
||||||
|
try:
|
||||||
|
form.save()
|
||||||
|
except IntegrityError:
|
||||||
|
messages.error(self.request, _("sorry! someone else got to that username first."))
|
||||||
|
return self.form_invalid(form)
|
||||||
messages.success(self.request, _("that's it! just log in, and you're ready to go."))
|
messages.success(self.request, _("that's it! just log in, and you're ready to go."))
|
||||||
return redirect("login")
|
return redirect("login")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue