feat: 支持自定义认证 backend;统一其他认证方式的信号触发逻辑;

pull/8803/head
Jiangjie.Bai 2022-08-24 17:38:17 +08:00
parent 7151201d58
commit 9123839b48
1 changed files with 3 additions and 5 deletions

View File

@ -1,6 +1,4 @@
import os
from django.conf import settings
import inspect
from django.utils.module_loading import import_string
from common.utils import get_logger
from django.contrib.auth import get_user_model
@ -15,6 +13,9 @@ logger = get_logger(__file__)
class CustomAuthBackend(JMSModelBackend):
custom_auth_method_path = 'data.auth.main.authenticate'
def load_authenticate_method(self):
return import_string(self.custom_auth_method_path)
def is_enabled(self):
try:
self.load_authenticate_method()
@ -35,9 +36,6 @@ class CustomAuthBackend(JMSModelBackend):
)
return user, created
def load_authenticate_method(self):
return import_string(self.custom_auth_method_path)
def authenticate(self, request, username=None, password=None, **kwargs):
try:
authenticate = self.load_authenticate_method()