update
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
from django.http.response import JsonResponse
|
||||
from rest_framework.views import APIView
|
||||
from django.http import HttpResponse
|
||||
|
||||
from server_auth.models import MindUser
|
||||
|
||||
|
||||
class MindUserView(APIView):
|
||||
@@ -12,4 +14,5 @@ class MindUserView(APIView):
|
||||
user_name = data_dict.get('userName')
|
||||
input_password = data_dict.get('inputPassword')
|
||||
print('userName:%s,inputPassword:%s' % (user_name, input_password))
|
||||
return HttpResponse("success")
|
||||
MindUser.objects.create_user(username=user_name, password=input_password, email='')
|
||||
return JsonResponse({"code": 0, "msg": "success"})
|
||||
|
||||
@@ -3,6 +3,7 @@ from server_auth.models import MindUser
|
||||
|
||||
from django.contrib.auth import authenticate, login, logout
|
||||
|
||||
|
||||
class AuthBackend(ModelBackend):
|
||||
"""
|
||||
login 方法会调用该方法
|
||||
@@ -14,12 +15,9 @@ class AuthBackend(ModelBackend):
|
||||
if user is not None and user.check_password(password):
|
||||
return user
|
||||
|
||||
|
||||
# 登录方式有多种
|
||||
# 1、用户名密码登录:直接匹配数据库的用户名密码
|
||||
|
||||
def login():
|
||||
pass
|
||||
|
||||
# 2、微信扫码登录:1、生成带标记的二维码 2、用户扫码 3、微信通知服务器端 4、服务器校验是否有注册,如果没有注册则新增用户 5、服务器通知前端界面
|
||||
|
||||
|
||||
@@ -24,16 +24,16 @@
|
||||
$(function () {
|
||||
// 监听modal窗口事件
|
||||
$('#exampleModal').on('show.bs.modal', function (event) {
|
||||
console.log(qr_websocket)
|
||||
console.log('打开');
|
||||
// console.log(qr_websocket)
|
||||
// console.log('打开');
|
||||
const ws = new WebSocket(`ws://${window.location.host}/ws/qr/?${qr_websocket.uuid}`)
|
||||
ws.onmessage = function (e) {
|
||||
console.log(e.data)
|
||||
console.log('接收到websocket消息:' + e.data)
|
||||
}
|
||||
qr_websocket.websocket = ws
|
||||
});
|
||||
$('#exampleModal').on('hidden.bs.modal', function (event) {
|
||||
console.log('关闭');
|
||||
// console.log('关闭');
|
||||
qr_websocket.websocket.close()
|
||||
});
|
||||
|
||||
@@ -89,7 +89,10 @@
|
||||
data: {userName: userName, inputPassword: inputPassword},
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
console.log(data)
|
||||
// 注册成功
|
||||
if (data.code === 0) {
|
||||
|
||||
}
|
||||
},
|
||||
async: false
|
||||
});
|
||||
@@ -150,7 +153,7 @@
|
||||
<div class="modal-body register_group" style="display: none;height: 360px;">
|
||||
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||
<label for="userName" class="sr-only"></label>
|
||||
<input type="email" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
|
||||
<input type="text" id="userName" class="form-control" placeholder="用户名" autocomplete="off" required autofocus>
|
||||
|
||||
<label for="inputPassword" class="sr-only"></label>
|
||||
<input type="password" id="inputPassword" class="form-control" placeholder="密码" required>
|
||||
@@ -166,7 +169,7 @@
|
||||
<div class="modal-body pw_login_group" style="display: none;height: 360px;">
|
||||
<h1 class="h3 mb-3 font-weight-normal">请输入用户名和密码</h1>
|
||||
<label for="userName" class="sr-only">Email address</label>
|
||||
<input type="email" id="userName" class="form-control" placeholder="Email address" required autofocus>
|
||||
<input type="text" id="userName" class="form-control" placeholder="Email address" required autofocus>
|
||||
|
||||
<label for="inputPassword" class="sr-only">Password</label>
|
||||
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
|
||||
|
||||
Reference in New Issue
Block a user