update
This commit is contained in:
@@ -1,3 +1,20 @@
|
||||
from django.contrib.auth.backends import ModelBackend # 验证基类
|
||||
from server_auth.models import MindUser
|
||||
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
|
||||
class AuthBackend(ModelBackend):
|
||||
"""
|
||||
login 方法会调用该方法
|
||||
"""
|
||||
|
||||
# 重写验证方式
|
||||
def authenticate(self, request, username=None, password=None, **kwargs):
|
||||
user = MindUser.objects.get(id=1)
|
||||
if user is not None and user.check_password(password):
|
||||
return user
|
||||
|
||||
|
||||
# 登录方式有多种
|
||||
# 1、用户名密码登录:直接匹配数据库的用户名密码
|
||||
|
||||
|
||||
Reference in New Issue
Block a user