File tree Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Expand file tree Collapse file tree 2 files changed +2
-6
lines changed Original file line number Diff line number Diff line change 1
- import importlib
2
-
3
1
from django .contrib .auth import authenticate , get_user_model
4
2
from django .contrib .auth .models import update_last_login
5
3
from django .utils .translation import gettext_lazy as _
8
6
from .settings import api_settings
9
7
from .tokens import RefreshToken , SlidingToken , UntypedToken
10
8
11
- rule_package , user_eligible_for_login = api_settings .USER_AUTHENTICATION_RULE .rsplit ('.' , 1 )
12
- login_rule = importlib .import_module (rule_package )
13
-
14
9
15
10
class PasswordField (serializers .CharField ):
16
11
def __init__ (self , * args , ** kwargs ):
@@ -47,7 +42,7 @@ def validate(self, attrs):
47
42
48
43
self .user = authenticate (** authenticate_kwargs )
49
44
50
- if not getattr ( login_rule , user_eligible_for_login ) (self .user ):
45
+ if not api_settings . USER_AUTHENTICATION_RULE (self .user ):
51
46
raise exceptions .AuthenticationFailed (
52
47
self .error_messages ['no_active_account' ],
53
48
'no_active_account' ,
Original file line number Diff line number Diff line change 42
42
IMPORT_STRINGS = (
43
43
'AUTH_TOKEN_CLASSES' ,
44
44
'TOKEN_USER_CLASS' ,
45
+ 'USER_AUTHENTICATION_RULE' ,
45
46
)
46
47
47
48
REMOVED_SETTINGS = (
You can’t perform that action at this time.
0 commit comments