Beispiel #1
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data,
            email=form.email.data, password=form.password.data)
        db.session.add(user)
        db.session.commit()
        
        token = user.generate_confirmation_token()
        send_confirmation_email(user)
        flash('确认邮件已发送至您的邮箱,请点击其中链接完成注册')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html', title='注册', form=form)
Beispiel #2
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(username=form.username.data, email=form.email.data)
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        send_confirmation_email(user)
        flash('A confirmation email has been sent to you by email.')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html',
                           title=_('Register'),
                           form=form)
Beispiel #3
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(
            username=form.username.data,
            email=form.email.data.lower(),
            confirmed=False,
        )
        user.set_password(form.password.data)
        db.session.add(user)
        db.session.commit()
        send_confirmation_email(user)
        login_user(user)
        return redirect(url_for('auth.unconfirmed'))
    return render_template('auth/register.html', title='Register', form=form)
Beispiel #4
0
def register():
    if current_user.is_authenticated:
        return redirect(url_for('main.index'))
    form = RegistrationForm()
    if form.validate_on_submit():
        username = form.username.data
        roles_dict = {"臭猪": "StinkyPiggy", "傻猪": "SillyPiggy"}
        role = Role.query.filter_by(name=roles_dict[username]).first()
        if role.check_validation_hash(str(form.birthday.data)):
            user = User(username=username,
                        role=role,
                        email=form.email.data,
                        password=form.password.data)
            db.session.add(user)
            db.session.commit()

            send_confirmation_email(user)
            flash('确认邮件已发送至您的邮箱,请点击其中链接完成注册')
            return redirect(url_for('main.index'))
        else:
            flash('生日输入错误')
    return render_template('auth/register.html', title='注册', form=form)
Beispiel #5
0
def resend_confirmation():
    send_confirmation_email(current_user)
    flash('确认邮件已发送至您的邮箱')
    return redirect(url_for('main.index'))
Beispiel #6
0
def resend_confirmation():
    if current_user.confirmed:
        return redirect('main.index')
    send_confirmation_email(current_user)
    flash('A new confirmation link has been sent to your email', 'warning')
    return render_template('auth/unconfirmed.html')
Beispiel #7
0
def resend_confirmation():
    send_confirmation_email(current_user)
    flash(_('A new confirmation email has been sent to you by email.'))
    return redirect(url_for('main.index'))