def register_user(): form = RegisterForm() if request.method == 'POST': if form.validate_on_submit(): print(form) return redirect('/') return render_template("register1.htm",**locals())
def register(): form = RegisterForm() if form.validate_on_submit(): #根据数据生成对象 u = User( username=form.username.data, email=form.email.data, password=form.password.data, ) print('*' * 50) print(u.username) #保存对象 db.session.add(u) # 必须提交 db.session.commit() token = u.generate_activate_token() send_mail('Paddy论坛账户激活', form.email.data, 'user/activate', username=form.username.data, token=token) flash('邮件已发送,请点击链接完成用户激活') #跳转页面 return redirect(url_for('main.index')) return render_template('user/register.html', form=form)
def register_user(): form = RegisterForm(request.form) if request.method == 'POST': # 验证成功,返回True,否则返回False if form.validate_on_submit(): # 获取验证数据 username = form.username.data password = form.password.data user = User(username=username) # 保存用户信息 user.password = hashlib.sha1(password.encode('utf8')).hexdigest() db.session.add(user) db.session.commit() return redirect("/") return render_template("register.html", **locals())
def register(): form = RegisterForm(request.form) if request.method == 'POST': if form.validate_on_submit(): # 获取验证数据 username = form.nickname.data.upper() password = form.password.data user = User(username=username) # 保存用户信息 user.password = hashlib.sha256(password.encode()).hexdigest() db.session.add(user) db.session.commit() user = User.query.filter(User.username == username).first() session['uid'] = user.uid return redirect(url_for('user.blog')) return render_template('register.htm', **locals())
def register(): form = RegisterForm(request.form) if request.method == 'POST': if form.validate_on_submit(): # 获取数据 phone = form.phone.data username = form.username.data password = form.password.data # 创建用户 user = User() user.username = username user.password = password user.phone = phone user.portrait = "/static/img/avatar-1.jpg" # user.regtime = datetime.datetime.now() user.email = "*****@*****.**" # 将用户存到数据库 db.session.add(user) db.session.commit() return redirect(url_for('bp.login')) return render_template('register.htm', **locals())