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

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

项目:lug-vpn-web    作者:ustclug    | 项目源码 | 文件源码
def login():
    if current_user.is_authenticated:
        return redirect(url_for('index'))
    form = LoginForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            email = form['email'].data
            password = form['password'].data
            user = User.get_user_by_email(email)
            if not user:
                flash('Email not found', 'error')
            elif not user.check_password(password):
                flash('Email or password incorrect', 'error')
            elif not user.active:
                flash('Email not confirmed. Please recover your account at the bottom of this page.', 'error')
            else:
                login_user(user)
                return redirect(url_for('index'))
    return render_template('login.html', form=form)
项目:InfoSub    作者:CoderHito    | 项目源码 | 文件源码
def validate_old_password(self, field):
        if current_user.check_password(field.data):
            return
        raise ValidationError(u"????")
项目:InfoSub    作者:CoderHito    | 项目源码 | 文件源码
def validate_check_password(self, field):
        if current_user.check_password(field.data):
            if current_user.role == "admin":
                raise ValidationError(u"????????_(:???)_")
            return
        raise ValidationError(u"??????")
项目:pyt    作者:python-security    | 项目源码 | 文件源码
def validate_old_password(self, field):
        if not current_user.check_password(field.data):
            raise ValidationError(_("Old Password is wrong."))
项目:hotface    作者:linhanqiuinc24    | 项目源码 | 文件源码
def validate_old_password(self, field):
        if not current_user.check_password(field.data):
            raise ValidationError(_("Old password is wrong."))
项目:hotface    作者:linhanqiuinc24    | 项目源码 | 文件源码
def validate_old_password(self, field):
        if not current_user.check_password(field.data):
            raise ValidationError(_("Old password is wrong."))
项目:lug-vpn-web    作者:ustclug    | 项目源码 | 文件源码
def changepassword():
    form = ChangePasswordForm()
    if request.method == 'POST':
        if form.validate_on_submit():
            oldpassword = form['oldpassword'].data
            password = form['password'].data
            if not current_user.check_password(oldpassword):
                flash('Current password incorrect', 'error')
            else:
                current_user.set_password(password)
                current_user.save()
                flash('Password successfully changed')
                return redirect(url_for('index'))
    return render_template('changepassword.html', form=form)