make sure usernames are valid slugs (bug 593501)
This commit is contained in:
Родитель
39f7e94cee
Коммит
43ed4e0bf8
|
@ -11,8 +11,9 @@ import commonware.log
|
|||
import happyforms
|
||||
from tower import ugettext as _, ugettext_lazy as _lazy
|
||||
|
||||
from amo.utils import slug_validator
|
||||
from .models import UserProfile, BlacklistedUsername, BlacklistedEmailDomain
|
||||
import tasks
|
||||
from . import tasks
|
||||
|
||||
log = commonware.log.getLogger('z.users')
|
||||
|
||||
|
@ -104,6 +105,7 @@ class UserRegisterForm(happyforms.ModelForm):
|
|||
|
||||
def clean_username(self):
|
||||
name = self.cleaned_data['username']
|
||||
slug_validator(name)
|
||||
if BlacklistedUsername.blocked(name):
|
||||
raise forms.ValidationError(_('This username is invalid.'))
|
||||
return name
|
||||
|
|
|
@ -47,7 +47,7 @@ class UserManager(amo.models.ManagerBase):
|
|||
|
||||
|
||||
class UserProfile(amo.models.ModelBase):
|
||||
|
||||
# nickname, firstname, & lastname are deprecated.
|
||||
nickname = models.CharField(max_length=255, default='', null=True,
|
||||
blank=True)
|
||||
firstname = models.CharField(max_length=255, default='', blank=True)
|
||||
|
|
Загрузка…
Ссылка в новой задаче