Disallow + in usernames.

master
Tom Hacohen 4 years ago
parent a7268443ca
commit 3d6ba634ce

@ -7,10 +7,10 @@ from django.utils.translation import gettext_lazy as _
@deconstructible @deconstructible
class UnicodeUsernameValidator(validators.RegexValidator): class UnicodeUsernameValidator(validators.RegexValidator):
regex = r'^[\w.+-]+\Z' regex = r'^[\w.-]+\Z'
message = _( message = _(
'Enter a valid username. This value may contain only letters, ' 'Enter a valid username. This value may contain only letters, '
'numbers, and ./+/-/_ characters.' 'numbers, and ./-/_ characters.'
) )
flags = 0 flags = 0
@ -29,7 +29,7 @@ class User(AbstractUser):
_('username'), _('username'),
max_length=150, max_length=150,
unique=True, unique=True,
help_text=_('Required. 150 characters or fewer. Letters, digits and ./+/-/_ only.'), help_text=_('Required. 150 characters or fewer. Letters, digits and ./-/_ only.'),
validators=[username_validator], validators=[username_validator],
error_messages={ error_messages={
'unique': _("A user with that username already exists."), 'unique': _("A user with that username already exists."),

Loading…
Cancel
Save