Skip to content

Commit

Permalink
Merge pull request #233 from lzaoral/allow-slash-username
Browse files Browse the repository at this point in the history
django: allow '/' character in usernames
  • Loading branch information
rohanpm committed Nov 16, 2023
2 parents 424b279 + 32ff0cb commit 2ba89f2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
19 changes: 19 additions & 0 deletions kobo/django/auth/migrations/0003_alter_user_username.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 3.2.20 on 2023-11-16 11:30

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('kobo_auth', '0002_auto_20220203_1511'),
]

operations = [
migrations.AlterField(
model_name='user',
name='username',
field=models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 255 characters or fewer. Letters, digits and @.+-_/ only.', max_length=255, unique=True, validators=[django.core.validators.RegexValidator('^[\\w.@+\\-/]+$', 'Enter a valid username. This value may contain only letters, numbers and @.+-_/ characters.', 'invalid')], verbose_name='username'),
),
]
6 changes: 3 additions & 3 deletions kobo/django/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ class User(AbstractBaseUser, PermissionsMixin):
Username, password and email are required. Other fields are optional.
"""
username = models.CharField(_('username'), max_length=MAX_LENGTH, unique=True,
help_text=_('Required. %s characters or fewer. Letters, digits and @/./+/-/_ only.' % MAX_LENGTH),
help_text=_('Required. %s characters or fewer. Letters, digits and @.+-_/ only.' % MAX_LENGTH),
validators=[
validators.RegexValidator(r'^[\w.@+-]+$',
validators.RegexValidator(r'^[\w.@+\-/]+$',
_('Enter a valid username. '
'This value may contain only letters, numbers '
'and @/./+/-/_ characters.'), 'invalid'),
'and @.+-_/ characters.'), 'invalid'),
],
error_messages={
'unique': _("A user with that username already exists."),
Expand Down

0 comments on commit 2ba89f2

Please sign in to comment.