def me(): form = UpdatePasswordForm() if form.validate_on_submit(): original = request.form.get('orig_password') password = request.form.get('password') user = Auth.query.filter_by(password=Auth.encrypt(original)).first() if user: user.password = Auth.encrypt(password) db.session.commit() auth_logout() flash('Password updated, please login again!', category='success') return redirect(url_for('.auth')) flash('Original password incorrect!', category='error') return redirect(url_for('.me')) return render_template('me.html', form=form)
def auth(): form = AuthForm() if form.validate_on_submit(): password = request.form.get('password') if not Auth.query.filter_by(password=Auth.encrypt(password)).first(): flash('Password incorrect!', category='error') return redirect(url_for('.auth')) auth_login() return redirect(request.args.get('next') or url_for('.index')) return render_template('auth.html', form=form)