def delete_user(): form = DeleteForm() if request.method == 'POST': if form.validate_on_submit(): if current_user.authenticate(form.password.data) and hasattr(current_user, 'id'): runs = db.session.query(Run).filter(Run.runner_id == current_user.id) objectives = db.session.query(Objective).filter(Objective.runner_id == current_user.id) reports = db.session.query(Report).filter(Report.runner_id == current_user.id) for run in runs.all(): db.session.delete(run) for report in reports.all(): db.session.delete(report) for objective in objectives.all(): db.session.delete(objective) db.session.delete(current_user) db.session.commit() logout_user() # This will also clean up the remember me cookie if it exists. return redirect('/') else: flash("Incorrect password", category='error') return make_response(render_template("delete_user.html", form=form), 401) else: abort(400) return render_template("delete_user.html", form=form)
def change_pass(self): current_pass = request.args.get('current_pass') new_pass = request.args.get('new_pass') if current_user.authenticate(current_pass): if new_pass: db.changePassword(current_user.id, new_pass) return jsonify({"status": "password_changed"}) return jsonify({"status": "no_password"}) else: return jsonify({"status": "wrong_user_pass"})
def change_pass(self): current_pass = request.args.get('current_pass') new_pass = request.args.get('new_pass') if current_user.authenticate(current_pass): if new_pass: db.changePassword(current_user.id , new_pass) return jsonify({"status": "password_changed"}) return jsonify({"status": "no_password"}) else: return jsonify({"status": "wrong_user_pass"})
def change_pass(): post_data = dict(request.json) current_pass = post_data["current_pass"] new_pass = post_data["new_pass"] if current_user.authenticate(current_pass): if new_pass: dbh.connection.changePassword(current_user.id, new_pass) return jsonify({"status": "password_changed"}) return jsonify({"status": "no_password"}) else: return jsonify({"status": "wrong_user_pass"})
def change_password(): uid = current_user.get_id() pw_old = request.form['oldpwd'] if not current_user.authenticate(pw_old): flash_error("Ooops, old password is wrong!") return flask.redirect(url_for(".info")) pw1 = request.form['password1'] pw2 = request.form['password2'] if pw1 != pw2: flash_error("Oops, new passwords do not match!") return flask.redirect(url_for(".info")) userdb.change_password(uid, pw1) flask.flash(Markup("Your password has been changed.")) return flask.redirect(url_for(".info"))
def change_password(): uid = current_user.get_id() pw_old = request.form['oldpwd'] if not current_user.authenticate(pw_old): flask.flash("Ooops, old password is wrong!", "error") return flask.redirect(url_for(".info")) pw1 = request.form['password1'] pw2 = request.form['password2'] if pw1 != pw2: flask.flash("Oops, new passwords do not match!", "error") return flask.redirect(url_for(".info")) userdb.change_password(uid, pw1) flask.flash("Your password has been changed.") return flask.redirect(url_for(".info"))
def change_password(): email = current_user.email pw_old = request.form["oldpwd"] if not current_user.authenticate(pw_old): flash_error("Ooops, old password is wrong!") return redirect(url_for(".info")) pw1 = request.form["password1"] pw2 = request.form["password2"] if pw1 != pw2: flash_error("Oops, new passwords do not match!") return redirect(url_for(".info")) if len(pw1) < 8: flash_error("Oops, password too short. Minimum 8 characters please!") return redirect(url_for(".info")) userdb.change_password(email, pw1) flask.flash(Markup("Your password has been changed.")) return redirect(url_for(".info"))