Python flask_login.current_user 模块,confirm() 实例源码

我们从Python开源项目中,提取了以下31个代码示例,用于说明如何使用flask_login.current_user.confirm()

项目:learning_flask2    作者:yuyilei    | 项目源码 | 文件源码
def register() :
    form = RegistrationForm() 
    if form.validate_on_submit() :
        user = User(email=form.email, username=form.username.data , password = form.password.data)
        db.session.add(User)
        flash('You can now login.')
        return  redirect(url_for('auth.login'))
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_mail(user.mail,'Confirm Your Account' ,'auth/email/confirm',user=user,token =token)
        flash('A confirmation email has been sent to you by email')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html',form = form)


#???????
项目:learning_flask2    作者:yuyilei    | 项目源码 | 文件源码
def unconfirmed() :
    if current_user.is_anonymous() or current_user.confirmed :
        return redirect(url_for('auth.unconfirmed')
    return render_template('auth/unconfirmed.html')


#??????????
@auth.route('/confirm')
@login_required
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email,'Confim Your Accout' , 'auth/email/confirm',user=current_user,token=token)
    flash('A new confirmation email has been sent to you by email.')
    return redirect(url_for('main.index'))


# ???????
@main.route('/user/<username>')
def user(username) :
    user = User.query.filter_by(username=username).first()
    if user is None :
        abort(404) 
    return render_template('user.html',user=user)
项目:Graduation_design    作者:mr-betterman    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        if form.user_type.data == '0':
            role = 2
        else:
            role = 3
        user = orm.User(email=form.email.data, username=form.username.data, password=form.password.data, role_id = role)
        token = user.generate_confirmation_token()
        try:
            send_email(user.email, '????',
                       'auth/email/confirm', user=user, token=token)
        except Exception:
            flash(u'??????.')
            return redirect(url_for('register'))
        else:
            db.session.add(user)
            db.session.commit()
            flash(u'????????????????.')
            return redirect(url_for('login'))
    elif request.method == 'GET':
        logic.LoadBasePageInfo('??', form)
    return render_template('auth/register.html', form=form)
项目:MyFlasky    作者:aliasxu    | 项目源码 | 文件源码
def confirm(token):

    if current_user.confirmed:
        # print current_user
        # print type(current_user)
        # print current_user.id
        # print current_app.config
        #?????????????????
        return redirect(url_for('main.index'))
    #??token
    if current_user.confirm(token):
        flash('You have confirmed your account.Thanks!')
    else:
        flash('The confirmation link is invalid or has expried')

    return redirect(url_for('main.index'))


#??????????
项目:learning_flask2    作者:yuyilei    | 项目源码 | 文件源码
def confirm(token) :
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    if current_user.confirm(token) :
        flash('Your have confirmed your account . Thanks!')
    else :
        flash('The confirmation link is invalid or has exired.')
    return redirect(url_for('main.index'))

#???????? , ????????
项目:Graduation_design    作者:mr-betterman    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('view_rents'))
    if current_user.confirm(token):
        flash(u'??????????')
    else:
        flash(u'?????')
    return redirect(url_for('view_rents'))
项目:Graduation_design    作者:mr-betterman    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, '????',
               'auth/email/confirm', user=current_user, token=token)
    flash(u'???????????????????')
    return redirect(url_for('view_rents'))
项目:ButterSalt    作者:lfzyx    | 项目源码 | 文件源码
def signup():
    form = SignupForm()
    if form.validate_on_submit():
        me = models.Users(email=form.email.data, username=form.username.data, password=form.password0.data)
        db.session.add(me)
        db.session.commit()
        token = me.generate_confirmation_token()
        send_email(me.email, 'Confirm Your Account',
                   'mail/user/confirm', user=user, token=token)
        flash('A confirmation email has been sent to you by email.')
        return redirect(request.args.get('next') or url_for('home.index'))
    return render_template('user/signup.html', form=form)
项目:ButterSalt    作者:lfzyx    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('home.index'))
    if current_user.confirm(token):
        flash('You have confirmed your account. Thanks!')
    else:
        flash('The confirmation link is invalid or has expired.')
    return redirect(url_for('home.index'))
项目:ButterSalt    作者:lfzyx    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account',
               'mail/user/confirm', user=current_user, token=token)
    flash('A new confirmation email has been sent to you by email.')
    return redirect(url_for('home.index'))
项目:ButterSalt    作者:lfzyx    | 项目源码 | 文件源码
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = form.email.data
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email, 'Confirm your email address',
                       'mail/user/change_email',
                       user=current_user, token=token)
            flash('An email with instructions to confirm your new email '
                  'address has been sent to you.')
            return redirect(url_for('home.index'))
        else:
            flash('Invalid password.')
    return render_template("user/change_email.html", form=form)
项目:zheye    作者:mathbugua    | 项目源码 | 文件源码
def login_register():
    login_form = LoginForm()
    register_form = RegistrationForm()
    # ?????????
    if login_form.submit1.data and login_form.validate_on_submit():
        user = User.query.filter_by(email=login_form.email.data).first()
        if user is not None and user.verify_password(login_form.password.data):
            login_user(user, login_form.remember_me.data)
            return redirect(url_for('main.index'))
        flash(constant.WRONG)

    # ?????????
    if register_form.submit2.data and register_form.validate_on_submit():
        user = User(email=register_form.email.data,
                    username=register_form.username.data,
                    password=register_form.password.data,
                    name=register_form.username.data)
        db.session.add(user)
        db.session.commit()
        try:
            token = user.generate_confirmation_token()
            send_email(user.email, 'Confirm Your Account',
                       'auth/email/confirm', user=user, token=token)
            flash(constant.SEND_EMIAL)
        except Exception as e:
            print e
        return redirect(url_for('auth.login_register'))

    return render_template('auth/login.html', form1=login_form, form2=register_form)
项目:zheye    作者:mathbugua    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    if current_user.confirm(token):
        flash(constant.VERIFI_SUCCESS)
    else:
        flash(constant.LINK_FAIL)
    return redirect(url_for('main.index'))
项目:zheye    作者:mathbugua    | 项目源码 | 文件源码
def resend_confirmation():
    """???????????"""
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account',
               'auth/email/confirm', user=current_user, token=token)
    flash(constant.SEND_EMIAL)
    return redirect(url_for('main.index'))
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username = form.username.data,
                    password = form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_email(user.email, 'Confirm Your Account', 'auth/email/confirm', user=user, token=token)
        flash('A confirmation email has been sent to you by email.')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', form=form)
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    if current_user.confirm(token):
        flash('You have confirmed your accont. Thanks!')
    else:
        flash('The confirmation link is invalid or has expired.')
    return redirect(url_for('main.index'))
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account', 'auth/email/confirm', user=current_user, token=token)
    flash('A new confirmation email has been sent to you by email.')
    return redirect(url_for('main.index'))
项目:LivroFlask    作者:antoniocsz    | 项目源码 | 文件源码
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = form.email.data
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email, 'Confirm your email address',
                       'auth/email/change_email',
                       user=current_user, token=token)
            flash('An email with instructions to confirm your new email '
                  'address has been sent to you.')
        else:
            flash('Invalid email or password.')
    return render_template('auth/change_email.html', form=form)
项目:Ticlab    作者:St1even    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email = form.email.data, username = form.username.data, password = form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_email(User.email, 'Confirm Your Account', 'auth/email/confirm', user = user, token = token)
        flash('A confirmation email has been sent to you by email.')
        login_user(user, False)
        return redirect(url_for('main.index'))
    return render_template('auth/register.html', form = form)
项目:Ticlab    作者:St1even    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    if current_user.confirm(token):
        flash('You have confirmed your account. Thanks!')
    else:
        flash('The confirmation link is invalid or has expired.')
    return redirect(url_for('main.index'))
项目:Ticlab    作者:St1even    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account', 'auth/email/confirm', user = current_user, token = token)
    flash('A new confirmation email has been sent to you by email')
    return redirect('main.index')
项目:Ticlab    作者:St1even    | 项目源码 | 文件源码
def change_email_request():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = form.email.data
            token = current_user.generate_email_change_token(new_email)
            send_email(new_email, 'Confirm your email address', 'auth/email/change_email', user = current_user, token = token)
            flash('An email with instructions to confirm your new email address has been sent to you')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid email or password')
    return render_template('auth/change_email.html', form = form)
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data, username=form.username.data, 
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()     # ?????????????????????????? id ??
        token = user.generate_confirmation_token()
        send_email(user.email, 'Confirm your account', 'auth/email/confirm', user=user, token=token)
        flash('a confirmation has been send to you by email')
        return redirect(url_for('auth.login'))
    return render_template('auth/register.html', form=form)
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    elif current_user.confirm(token):
        flash('you have confirmed your token')


    else:
        flash('The confirmation link is invalid or expired')
    return redirect(url_for('main.index'))
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm your account', 'auth/email/confirm', user=current_user, token=token)
    flash('a new confirmation has been send to you by email')
    return redirect(url_for('main.index'))
项目:blog    作者:hukaixuan    | 项目源码 | 文件源码
def reset_password(id, token):
    """????token????--?????????"""
    form = PasswordResetForm()
    user = User.query.filter_by(id=id).first()
    if not user or not user.confirm(token):
        return redirect(url_for('.reset_password_request'))
    if form.validate_on_submit():
        user.password = form.new_password.data
        db.session.add(user)
        flash('you have changed your password, please login')
        return redirect(url_for('.login'))
    return render_template('auth/password/reset.html', form=form)
项目:Faiwong-s-blog    作者:Fai-Wong    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,
                    username=form.username.data,
                    password=form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_email(user.email, 'Confirm Your Account', 
                'auth/email/confirm', user=user, token=token)
        flash(u'??????????????????')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html', form=form)
项目:Faiwong-s-blog    作者:Fai-Wong    | 项目源码 | 文件源码
def confirm(token):
    if current_user.confirmed:
        return redirect(url_for('main.index'))
    if current_user.confirm(token):
        flash(u'?????????. ??!')
    else:
        flash(u'?????????')
    return redirect(url_for('main.index'))
项目:Faiwong-s-blog    作者:Fai-Wong    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account', 
            'auth/email/confirm', user=current_user, token=token)
    flash(u'??????????????????')
    return redirect(url_for('main.index'))
项目:MyFlasky    作者:aliasxu    | 项目源码 | 文件源码
def register():
    form = RegistrationForm()
    if form.validate_on_submit():
        user = User(email=form.email.data,username = form.username.data,password = form.password.data)
        db.session.add(user)
        db.session.commit()
        token = user.generate_confirmation_token()
        send_email(user.email,'Confirm Your Account','/auth/email/confirm',user=user,token=token)
        flash('A confirmation email has been sent to you email.')
        return redirect(url_for('main.index'))
    return render_template('auth/register.html',form=form)


#????
项目:MyFlasky    作者:aliasxu    | 项目源码 | 文件源码
def resend_confirmation():
    token = current_user.generate_confirmation_token()
    send_email(current_user.email, 'Confirm Your Account',
               'auth/email/confirm', user=current_user, token=token)
    flash('A new confirmation email has been sent to you by email.')
    return redirect(url_for('main.index'))

#????