def user(id): user = User.find(id) form = UserInfoEditForm() if len(user) == 0: flash('User not found') return redirect(url_for('index')) if form.validate_on_submit(): user.name = form.name.data user.email = form.name.email user.update() return redirect(url_for('index')) return render_template('user.html', user=user, form=form)
def confirm(id): if g.user is not None and g.user.is_authenticated: return redirect(url_for('index')) user = User.find(id) if not user: return redirect(url_for('register')) elif int(time.time()) - user.created_at > 3600: user.remove() return redirect(url_for('register')) elif user.id != id: return redirect(url_for('register')) # 验证正确,将数据保存到数据库 user.isconfirmed = True user.update() login_user(user, remember=True) return redirect(url_for('index'))
def load_user(id): return User.find(id)
def userview(id): user = User.find(id) if g.user is not None and g.user.is_authenticated: return render_template('userview.html', userview=user, user=g.user) return render_template('userview.html', userview=user)