MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / api_upload_init

Function api_upload_init

Scripts/ButSystem.py:11746–11783  ·  view source on GitHub ↗

api_upload_init. Internal helper function. This docstring was added automatically to improve maintainability. Returns: Varies.

()

Source from the content-addressed store, hash-verified

11744This docstring was added automatically to improve maintainability.
11745
11746Args:
11747 username: Parameter.
11748 q1: Parameter.
11749 q2: Parameter.
11750 q3: Parameter.
11751 a1: Parameter.
11752 a2: Parameter.
11753 a3: Parameter.
11754 enabled: Parameter.
11755
11756Returns:
11757 Varies.
11758"""
11759 q1, q2, q3 = (q1 or "").strip()[:120], (q2 or "").strip()[:120], (q3 or "").strip()[:120]
11760 # Store hashed answers (PBKDF2 via werkzeug)
11761 a1h = generate_password_hash(_norm_answer(a1)) if a1 else None
11762 a2h = generate_password_hash(_norm_answer(a2)) if a2 else None
11763 a3h = generate_password_hash(_norm_answer(a3)) if a3 else None
11764 en = 1 if enabled else 0
11765
11766 conn = db_connect()
11767 conn.execute(
11768 """INSERT INTO user_security(username,q1,q2,q3,a1_hash,a2_hash,a3_hash,enabled,updated_at)
11769 VALUES(?,?,?,?,?,?,?,?,?)
11770 ON CONFLICT(username) DO UPDATE SET
11771 q1=excluded.q1, q2=excluded.q2, q3=excluded.q3,
11772 a1_hash=COALESCE(excluded.a1_hash, user_security.a1_hash),
11773 a2_hash=COALESCE(excluded.a2_hash, user_security.a2_hash),
11774 a3_hash=COALESCE(excluded.a3_hash, user_security.a3_hash),
11775 enabled=excluded.enabled,
11776 updated_at=excluded.updated_at
11777 """,
11778 (username, q1, q2, q3, a1h, a2h, a3h, en, now_z())
11779 )
11780 conn.commit()
11781 conn.close()
11782
11783def verify_security_answers(username: str, answers: dict) -> bool:
11784 """verify_security_answers.
11785
11786Internal helper function.

Callers

nothing calls this directly

Calls 5

safe_relpathFunction · 0.70
current_userFunction · 0.70
now_zFunction · 0.70
_upload_meta_pathFunction · 0.70

Tested by

no test coverage detected