代码拉取完成,页面将自动刷新
同步操作将从 zvms/zvms-backend 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
from flask import Blueprint, request
from deco import *
import tokenlib as TK
import json
import res
import traceback
import oppressor as OP
User = Blueprint('user', __name__)
@User.route('/user/login', methods = ['POST','OPTIONS','GET'])
@Deco
def login_NoToken():
userid = json_data().get("userid")
password = json_data().get("password")
version = json_data().get("version")
if version != res.CURRENT_VERSION:
return {"type": "ERROR", "message": res.CURRENT_VERSION_ERROR_MESSAGE}
st, val = OP.userLogin(userid, password)
ret={}
if st:
ret.update({"type":"SUCCESS", "message":"登入成功!"})
ret.update(OP.user2dict(val))
ret.update({"token":TK.generateToken({
"userid": userid,
"username": ret['username'],
"class": ret['class'],
"permission": ret['permission']
})})
else:
ret.update({"type": "ERROR", "message": "用户名或密码错误"})
traceback.print_exc()
ret.update(val)
return ret
@User.route('/user/logout', methods = ['GET','OPTIONS','POST'])
@Deco
def logout_NoToken():
return {'type': 'SUCCESS', 'message': '登出成功!'}
#最好在这里做点什么吧,比如删除cookie什么的
@User.route('/user/info', methods = ['GET','POST','OPTIONS'])
@Deco
def info():
return {'type':'SUCCESS', 'message':"获取成功", 'info':tkData()}
@User.route('/user/getInfo/<int:userId>', methods=['POST'])
@Deco
def getInfo(userId):
fl,r=OP.select("userName,class,permission","user","userId=%s",userId,["userName","class","permission"])
if not fl: return r
r.update({"type":"SUCCESS", "message":"获取成功"})
return r
@User.route('/user/modPwd', methods = ['POST'])
@Deco
def modifyPassword():
old=json_data().get("oldPwd")
new=json_data().get("newPwd")
fl, r = OP.select("userid","user", "userId = %s and password = %s", (tkData().get("userid"), old), ["user"])
if not fl: return {"type": "ERROR", "message": "密码错误"}
print(type(tkData().get("userid")))
OP.update("password=%s","user","userId=%s",(new, tkData().get("userid"),))
return {"type":"SUCCESS", "message":"修改成功"}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。