From 9123839b48f1866fcd2193fe3a6b9191de84003f Mon Sep 17 00:00:00 2001 From: "Jiangjie.Bai" Date: Wed, 24 Aug 2022 17:38:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E6=8C=81=E8=87=AA=E5=AE=9A?= =?UTF-8?q?=E4=B9=89=E8=AE=A4=E8=AF=81=20backend=EF=BC=9B=E7=BB=9F?= =?UTF-8?q?=E4=B8=80=E5=85=B6=E4=BB=96=E8=AE=A4=E8=AF=81=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E7=9A=84=E4=BF=A1=E5=8F=B7=E8=A7=A6=E5=8F=91=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/authentication/backends/custom.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/apps/authentication/backends/custom.py b/apps/authentication/backends/custom.py index 4432e2919..3a0bafeb0 100644 --- a/apps/authentication/backends/custom.py +++ b/apps/authentication/backends/custom.py @@ -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()