3cd280d068
- Created a global CSS file for styling the frontend with responsive design. - Introduced TypeScript types for various entities including Research, Alpha, and Account. - Implemented Playwright tests for account management and data synchronization workflows. - Configured TypeScript with strict settings and included necessary libraries. - Set up Vite as the build tool with React plugin and API proxy configuration. - Added a Python script to initialize environment variables securely.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
"""Administrative commands run inside the backend container."""
|
|
|
|
import argparse
|
|
import asyncio
|
|
import getpass
|
|
|
|
from sqlalchemy import delete
|
|
|
|
from .config import Settings
|
|
from .db import create_database
|
|
from .models import Admin, LoginSession
|
|
from .security import password_hasher
|
|
|
|
|
|
async def reset_password():
|
|
password = getpass.getpass("New admin password (12+ characters): ")
|
|
if len(password) < 12 or password != getpass.getpass("Confirm password: "):
|
|
raise SystemExit("Password too short or confirmation does not match")
|
|
engine, sessions = create_database(Settings().database_url)
|
|
async with sessions() as db:
|
|
admin = await db.get(Admin, 1)
|
|
admin.password_hash = password_hasher.hash(password)
|
|
await db.execute(delete(LoginSession))
|
|
await db.commit()
|
|
await engine.dispose()
|
|
print("Admin password updated; all system sessions revoked.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("command", choices=["reset-password"])
|
|
parser.parse_args()
|
|
asyncio.run(reset_password())
|