Commit 385f47fca591bf66dc4c9181bb11309f487605e0
Committed by
Sergio Oliveira
1 parent
32509d34
Exists in
master
and in
39 other branches
Overwritten User save method to force lowercase
Showing
1 changed file
with
7 additions
and
1 deletions
Show diff stats
colab/accounts/models.py
| ... | ... | @@ -49,6 +49,12 @@ class User(AbstractUser): |
| 49 | 49 | def update_subscription(self, email, lists): |
| 50 | 50 | mailman.update_subscription(email, lists) |
| 51 | 51 | |
| 52 | + def save(self, *args, **kwargs): | |
| 53 | + | |
| 54 | + # Forces username to be lowercase always | |
| 55 | + self.username = self.username.lower() | |
| 56 | + super(User, self).save(*args, **kwargs) | |
| 57 | + | |
| 52 | 58 | |
| 53 | 59 | # We need to have `email` field set as unique but Django does not |
| 54 | 60 | # support field overriding (at least not until 1.6). |
| ... | ... | @@ -60,7 +66,7 @@ User._meta.get_field('username').help_text = _( |
| 60 | 66 | u'./+/-/_ only.' |
| 61 | 67 | ) |
| 62 | 68 | User._meta.get_field('username').validators[0] = validators.RegexValidator( |
| 63 | - r'^[\w.+-]+$', | |
| 69 | + r'^\w+$', | |
| 64 | 70 | _('Enter a valid username.'), |
| 65 | 71 | 'invalid' |
| 66 | 72 | ) | ... | ... |