Python flask.ext.login.current_user 模块,verify_password() 实例源码

我们从Python开源项目中,提取了以下14个代码示例,用于说明如何使用flask.ext.login.current_user.verify_password()

项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            db.session.commit()
            flash('???????')
            return redirect(url_for('main.index'))
        else:
            flash('???????????')
            form.old_password.data = ''
            form.password.data = ''
            form.password2.data = ''
    return render_template('auth/change_password.html', form=form)

# ????????
项目:Blog_Flask    作者:xiaohu2015    | 项目源码 | 文件源码
def changeEmail():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            new_email = form.email.data
            token = current_user.generate_change_email_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)

#????????
项目:BookLibrary    作者:hufan-akari    | 项目源码 | 文件源码
def validate_old_password(self, filed):
        from flask.ext.login import current_user
        if not current_user.verify_password(filed.data):
            raise ValidationError(u'?????')
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user, form.remember_me.data)
            flash('????!')
            return redirect(request.args.get('next') or url_for('main.index'))
        flash('?????????')
    return render_template('auth/login.html', form=form)

# ????
项目:chihu    作者:yelongyu    | 项目源码 | 文件源码
def change_email():
    form = ChangeEmailForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.password.data):
            token = current_user.generate_change_email_token(form.email.data)
            send_mail(form.email.data, '??????', 'auth/email/change_email_confirm', user=current_user, token=token)
            flash('????????????????????????')
        else:
            flash('??????????!')
    return render_template('auth/change_email.html', form=form)

# ????
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user,form.remember_me.data)
            return redirect(request.args.get('next') or url_for('main.index'))
        flash('Invalid username or password.')
    return render_template('auth/login.html',form=form)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            flash('Your password has been updated.')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid password.')
    return render_template("auth/change_password.html", form=form)
项目:pyetje    作者:rorlika    | 项目源码 | 文件源码
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)
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email = form.email.data).first()
        if user is not None and user.verify_password(form.password.data):
            login_user(user, form.remember_me.data)
            return redirect(request.args.get('next') or url_for('main.index'))
        flash('Invalid username or password.')
    return render_template('auth/login.html', form = form)
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
def change_password():
    form = ChangePasswordForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            current_user.password = form.password.data
            db.session.add(current_user)
            flash('Your password has been updated.')
            return redirect(url_for('main.index'))
        else:
            flash('Invalid password.')
    return render_template('auth/change_password.html', form = form)
项目:project    作者:Junctionzc    | 项目源码 | 文件源码
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 '
                  'addredss 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)
项目:markbj    作者:chaijunit    | 项目源码 | 文件源码
def password():
    form = PasswordForm()
    if form.validate_on_submit():
        if not current_user.verify_password(form.old_password.data):
            form.old_password.errors.append("??????")
            return render_template("setting/password.html", form=form)
        flash("??????")
        current_user.password = current_user.generate_password_hash(form.password.data)
        return render_template("setting/password.html", form=form)
    return render_template("setting/password.html", form=form)
项目:Blog_Flask    作者:xiaohu2015    | 项目源码 | 文件源码
def login():
    form = LoginForm()
    if form.validate_on_submit():
        user = User.query.filter_by(email=form.email.data).first()
        if user is not None and user.verify_password(form.password.data):   #????
            login_user(user, form.remember_me.data)    #????????????????
            #??????????
            return redirect(request.args.get('next') or url_for('main.index'))
        #???????????????
        flash('????????.')
    return render_template('auth/login.html', form=form)

#????
项目:Blog_Flask    作者:xiaohu2015    | 项目源码 | 文件源码
def changepwd():
    form = ChangepwdForm()
    if form.validate_on_submit():
        if current_user.verify_password(form.old_password.data):
            #?????????????
            current_user.password = form.new_password.data
            db.session.add(current_user)
            #????
            flash('??????????')
            return redirect(url_for('main.index')) #??????
        else:
            flash('?????')
    return render_template('auth/changepwd.html', form=form)

#??????