Disallow non-alpha characters in username
This commit is contained in:
parent
b927491084
commit
1c54bd5923
|
@ -5,6 +5,7 @@ from rest_framework.exceptions import ValidationError
|
||||||
from rest_framework.validators import UniqueValidator
|
from rest_framework.validators import UniqueValidator
|
||||||
from rest_auth.registration.serializers import RegisterSerializer
|
from rest_auth.registration.serializers import RegisterSerializer
|
||||||
from rest_auth.serializers import UserDetailsSerializer
|
from rest_auth.serializers import UserDetailsSerializer
|
||||||
|
import re
|
||||||
|
|
||||||
from . import models, fields, utils
|
from . import models, fields, utils
|
||||||
from .. import settings
|
from .. import settings
|
||||||
|
@ -351,6 +352,11 @@ class RegistrationSerializer(RegisterSerializer):
|
||||||
last_name = serializers.CharField(max_length=32)
|
last_name = serializers.CharField(max_length=32)
|
||||||
existing_member = serializers.ChoiceField(['true', 'false'])
|
existing_member = serializers.ChoiceField(['true', 'false'])
|
||||||
|
|
||||||
|
def validate_username(self, username):
|
||||||
|
if re.search(r'[^a-z.]', username):
|
||||||
|
raise ValidationError('Invalid characters.')
|
||||||
|
return super().validate_username(username)
|
||||||
|
|
||||||
def custom_signup(self, request, user):
|
def custom_signup(self, request, user):
|
||||||
data = request.data
|
data = request.data
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user