()
| 12042 | if _rate_limit_hit("recover_post", ip, limit=10, window_sec=1800): |
| 12043 | flash("Too many recovery attempts. Try again later.") |
| 12044 | return render_template("recover.html", title="Recover") |
| 12045 | |
| 12046 | step = request.form.get("step") or "user" |
| 12047 | username = (request.form.get("username") or "").strip() |
| 12048 | |
| 12049 | if step == "user": |
| 12050 | if not username: |
| 12051 | flash("Username is required.") |
| 12052 | return render_template("recover.html", title="Recover") |
| 12053 | conn = db_connect() |
| 12054 | row = conn.execute("SELECT q1,q2,q3,enabled FROM user_security WHERE username=?", (username,)).fetchone() |
| 12055 | conn.close() |
| 12056 | if not row or not (row["q1"] and row["q2"] and row["q3"]): |
| 12057 | flash("Recovery is not set up for this user.") |
| 12058 | return render_template("recover.html", title="Recover") |
| 12059 | qs = [(1, row["q1"]), (2, row["q2"]), (3, row["q3"])] |
| 12060 | return render_template("recover.html", title="Recover", username=username, qs=qs, ask=True) |
| 12061 | |
| 12062 | # step == 'reset' |
| 12063 | new_pw = request.form.get("new_password") or "" |
| 12064 | new_pw2 = request.form.get("new_password2") or "" |
| 12065 | if not username or not new_pw or new_pw != new_pw2: |
| 12066 | flash("Passwords do not match.") |
| 12067 | return render_template("recover.html", title="Recover") |
nothing calls this directly
no test coverage detected