Real client IP with anti-spoofing. We only trust forwarded headers when the request comes from loopback (i.e., a local reverse-proxy like cloudflared/tor on the SAME device).
()
| 3562 | if row and row["pic_path"] and os.path.exists(row["pic_path"]): |
| 3563 | try: |
| 3564 | os.remove(row["pic_path"]) |
| 3565 | except Exception: |
| 3566 | pass |
| 3567 | conn.execute("UPDATE profiles SET pic_path=NULL, pic_mime=NULL, updated_at=? WHERE username=?", |
| 3568 | (now_z(), username)) |
| 3569 | conn.commit() |
| 3570 | conn.close() |
| 3571 | |
| 3572 | def user_root(username: str) -> str: |
| 3573 | """user_root. |
| 3574 | |
| 3575 | Internal helper function. |
| 3576 | |
| 3577 | This docstring was added automatically to improve maintainability. |
| 3578 | |
| 3579 | Args: |
| 3580 | username: Parameter. |
| 3581 | |
| 3582 | Returns: |
| 3583 | Varies. |
| 3584 | """ |
| 3585 | p = os.path.join(STORAGE_DIR, username) |
| 3586 | os.makedirs(p, exist_ok=True) |
| 3587 | return p |
| 3588 |
no test coverage detected