def setUserInfo(): userName = request.form['userName'] email = request.form['email'] if len(userName) < 2 or len(userName) > 20: flash(u"请输入2-20个字符的用户名!") return redirect(url_for('admin.userInfo')) if not reEmail(email): flash(u"邮箱【%s】格式不对,请重新输入!" % email) return redirect(url_for('admin.userInfo')) if current_user.userName != userName: if User.objects(userName=userName).first(): flash(u"用户名【%s】已经存在,请重新输入!" % userName) return redirect(url_for('admin.userInfo')) current_user.userName = userName current_user.email = email current_user.save() flash(u"信息修改成功!") return redirect(url_for('admin.userInfo'))
def load_user(id): return User.objects(id=id).first()