Files
mem0ai--mem0/server/scripts/reset_admin_password.py
wehub-resource-sync 555e282cc4
pi-agent-plugin checks / lint (push) Has been cancelled
pi-agent-plugin checks / test (20) (push) Has been cancelled
pi-agent-plugin checks / test (22) (push) Has been cancelled
pi-agent-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / check_changes (push) Has been cancelled
TypeScript SDK CI / changelog_check (push) Has been cancelled
ci / changelog_check (push) Has been cancelled
ci / check_changes (push) Has been cancelled
ci / build_mem0 (3.10) (push) Has been cancelled
ci / build_mem0 (3.11) (push) Has been cancelled
ci / build_mem0 (3.12) (push) Has been cancelled
CLI Node CI / lint (push) Has been cancelled
CLI Node CI / test (20) (push) Has been cancelled
CLI Node CI / test (22) (push) Has been cancelled
CLI Node CI / build (push) Has been cancelled
CLI Python CI / lint (push) Has been cancelled
CLI Python CI / test (3.10) (push) Has been cancelled
CLI Python CI / test (3.11) (push) Has been cancelled
CLI Python CI / test (3.12) (push) Has been cancelled
CLI Python CI / build (push) Has been cancelled
openclaw checks / lint (push) Has been cancelled
openclaw checks / test (20) (push) Has been cancelled
openclaw checks / test (22) (push) Has been cancelled
openclaw checks / build (push) Has been cancelled
opencode-plugin checks / build (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / build_ts_sdk (22) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (20) (push) Has been cancelled
TypeScript SDK CI / integration_ts_sdk (22) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:03:45 +08:00

42 lines
1.0 KiB
Python

"""Reset a user's password by email. Run inside the `mem0` container."""
import os
import sys
from sqlalchemy import select
from auth import hash_password
from db import SessionLocal
from models import User
MIN_PASSWORD_LENGTH = 8
def main() -> int:
email = os.environ.get("EMAIL", "").strip()
password = os.environ.get("PASSWORD", "")
if not email or not password:
print("error: EMAIL and PASSWORD environment variables are required.", file=sys.stderr)
return 2
if len(password) < MIN_PASSWORD_LENGTH:
print(f"error: password must be at least {MIN_PASSWORD_LENGTH} characters.", file=sys.stderr)
return 2
with SessionLocal() as db:
user = db.scalar(select(User).where(User.email == email))
if user is None:
print(f"error: no user found with email {email}.", file=sys.stderr)
return 1
user.password_hash = hash_password(password)
db.commit()
print(f"Password reset for {email}.")
return 0
if __name__ == "__main__":
sys.exit(main())