def update(): userName = request.cookies.get('username') #userName=request.form.get('userName') password = request.form.get('password') nickName = request.form.get('nickName') sex = request.form.get('sex') location = request.form.get('location') pic = request.form.get('pic') type = request.form.get('type') user = User.query.filter(User.userName == userName).first() if (user is None): return ResData.fail() if (password is not None): user.password = password if (nickName is not None): user.nickName = nickName if (sex is not None): user.sex = sex if (location is not None): user.location = location if (pic is not None): user.pic = pic if (type is not None): user.type = type db.session.add(user) db.session.commit() return ResData.success(None)
def login(): userName = request.form.get('userName') password = request.form.get('password') user = User.query.filter(User.userName == userName, User.password == password).first() if (user is None): return ResData.fail(userName) res = make_response(ResData.success(user.to_json())) res.set_cookie('username', userName) return res