示例#1
0
文件: auth.py 项目: ArvinHe/Blogin
def register():
    form = RegisterForm()
    if form.validate_on_submit():
        name = form.user_name.data
        pwd = form.confirm_pwd.data
        email = form.user_email.data.lower()
        user = User(username=name, email=email, password=pwd, )
        user.set_password(pwd)
        user.set_role()
        db.session.add(user)
        db.session.commit()
        token = generate_token(user, operation='confirm')
        send_confirm_email(user=user, token=token)
        flash('注册成功,欢迎加入Blogin.', 'success')
        return redirect(url_for('.login'))
    return render_template('main/register.html', form=form)
示例#2
0
文件: auth.py 项目: ArvinHe/Blogin
def resend_confirm_mail():
    user = current_user._get_current_object()
    token = generate_token(user=user, operation=Operations.CONFIRM)
    send_confirm_email(user=user, token=token)
    flash('邮箱认证邮件发送成功,请前往邮箱查看认证!', 'success')
    return redirect(request.referrer)