3 回答

TA贡献1887条经验 获得超5个赞
所以我通过这里的文件解决了我自己的问题:https ://docs.djangoproject.com/en/2.1/topics/auth/customizing/
我所要做的就是 auth_backend.py 中的 authetnicate 函数
def authenticate(self, username=None):
至
def authenticate(self, request, username=None):
在文档中它说您还可以将类声明更改为不包含 ModelBackend,但它可以以任何方式工作。

TA贡献1788条经验 获得超4个赞
您可以尝试避免使用默认后端吗?
改变
AUTHENTICATION_BACKENDS = [
# auth_backend.py implementing Class PasswordlessAuthBackend inside yourapp folder
'yourapp.auth_backend.PasswordlessAuthBackend',
# Default authentication of Django
'django.contrib.auth.backends.ModelBackend',
]
至
AUTHENTICATION_BACKENDS = [
# auth_backend.py implementing Class PasswordlessAuthBackend inside yourapp folder
'yourapp.auth_backend.PasswordlessAuthBackend',
]

TA贡献1797条经验 获得超6个赞
您在 settings.py 中的身份验证后端路径无效
yourapp.auth_backend.YourAuth
应该
yourapp.auth_backend.PasswordlessAuthBackend
添加回答
举报