def admin_login(): if request.method == 'POST': account = request.form.get('account',None) password = request.form.get('password',None) user = User.objects(account=account).first() a = get_md5(password) if user and user.password == get_md5(password): login_user(user) return redirect(url_for('task_show')) return render_template('taskManage/login.html')
def admin_change_password(): user = current_user password = request.form.get('password',None) oldPwd = request.form.get('oldPwd',None) oldPwd = get_md5(oldPwd) userAdmin = User.objects(myid=user.myid).first() if userAdmin: userOldPwd = userAdmin.password if (password is not None) and (oldPwd == userOldPwd): userAdmin.password = get_md5(password) userAdmin.save() return jsonify(dict(message=0)) else: if oldPwd != userOldPwd: return jsonify(dict(message=1)) return jsonify(dict(message=2))
def load_user(id): if str(id) == 'None': return None return User.objects(myid=int(id)).first()