profile_pic_upload. Route handler or application helper. This docstring was expanded to make future maintenance easier. Returns: Varies.
()
| 11394 | if p1 != p2: |
| 11395 | flash("Passwords do not match.") |
| 11396 | return render_template("signup.html", title="Request Access") |
| 11397 | pw_err = _password_strength_error(p1, u1) |
| 11398 | if pw_err: |
| 11399 | flash(pw_err) |
| 11400 | return render_template("signup.html", title="Request Access") |
| 11401 | if not re.fullmatch(r"[A-Za-z0-9_.-]{3,32}", u1): |
| 11402 | flash("Username must be 3-32 chars: letters, numbers, _ . -") |
| 11403 | return render_template("signup.html", title="Request Access") |
| 11404 | |
| 11405 | ip = _client_ip() or "?" |
| 11406 | pw_hash = generate_password_hash(p1) |
| 11407 | |
| 11408 | conn = db_connect() |
| 11409 | exists = conn.execute("SELECT 1 FROM users WHERE username=?", (u1,)).fetchone() |
| 11410 | if exists: |
| 11411 | conn.close() |
| 11412 | flash("That username already exists. Please login.") |
| 11413 | return redirect(url_for("login")) |
| 11414 | |
| 11415 | pend = conn.execute("SELECT status FROM pending_users WHERE username=?", (u1,)).fetchone() |
| 11416 | if pend: |
| 11417 | conn.close() |
| 11418 | if pend["status"] == "pending": |
| 11419 | flash("Your request is already pending approval.") |
| 11420 | elif pend["status"] == "denied": |
| 11421 | flash("Your request was denied.") |
| 11422 | else: |
| 11423 | flash("Your request was approved. You can login now.") |
| 11424 | return redirect(url_for("login")) |
| 11425 | |
| 11426 | conn.execute( |
| 11427 | "INSERT INTO pending_users(username, pw_hash, requested_ip, requested_at, status) VALUES(?,?,?,?, 'pending')", |
| 11428 | (u1, pw_hash, ip, now_z()) |
| 11429 | ) |
nothing calls this directly
no test coverage detected