我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用flask_login.current_user.check_password()。
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)
def validate_old_password(self, field): if current_user.check_password(field.data): return raise ValidationError(u"????")
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"??????")
def validate_old_password(self, field): if not current_user.check_password(field.data): raise ValidationError(_("Old Password is wrong."))
def validate_old_password(self, field): if not current_user.check_password(field.data): raise ValidationError(_("Old password is wrong."))
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)