File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from django .db import models
2+ from django .conf import settings
3+ from django .contrib .auth import validators
24from django .contrib .auth .models import AbstractUser
35from django .utils .translation import gettext_lazy as _
46
57from oauth2_provider .models import AbstractApplication
68
79
810class User (AbstractUser ):
11+ username_validator = validators .UnicodeUsernameValidator (
12+ regex = settings .USERNAME_REGEX ,
13+ message = _ ("Enter a valid username. This value may match the regex {}." .format (
14+ settings .USERNAME_REGEX
15+ ))
16+ )
917 email = models .EmailField (_ ('email address' ), unique = True )
1018
1119 @property
Original file line number Diff line number Diff line change 399399EMAIL_USE_TLS = os .environ .get ('EMAIL_USE_TLS' , 'false' ).lower () == "true"
400400EMAIL_USE_SSL = os .environ .get ('EMAIL_USE_SSL' , 'false' ).lower () == "true"
401401
402+ # username regex
403+ USERNAME_REGEX = os .environ .get ('USERNAME_REGEX' , '^[a-z][a-z0-9]{4,}$' )
404+ # hcaptcha config
402405H_CAPTCHA_KEY = os .environ .get ("H_CAPTCHA_KEY" )
403406H_CAPTCHA_SECRET = os .environ .get ("H_CAPTCHA_SECRET" )
You can’t perform that action at this time.
0 commit comments