Self-hosted dashboard and admin auth (#4837)

Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
Gabriel Stein
2026-04-23 19:06:36 +05:30
committed by GitHub
co-authored by kartik-mem0
parent 15feaa8ac4
commit db8ac61713
252 changed files with 20275 additions and 331 deletions
+41
View File
@@ -0,0 +1,41 @@
"""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())