diff --git a/backend/ecosystem.config.js b/backend/ecosystem.config.js index 277bb8f..eebd798 100644 --- a/backend/ecosystem.config.js +++ b/backend/ecosystem.config.js @@ -27,7 +27,7 @@ module.exports = { SMTP_PASS: "wkbk mwbi aiqo yvwl", SMTP_FROM_NAME: "Quantfortune Support", - SUPER_ADMIN_EMAIL: "admin@example.com", + SUPER_ADMIN_EMAIL: "thigazhezhilanj007@gmail.com", SUPER_ADMIN_PASSWORD: "AdminPass123!", RESET_OTP_SECRET: "change_this_secret" } diff --git a/backend/promote_super_admin.py b/backend/promote_super_admin.py new file mode 100644 index 0000000..d639c84 --- /dev/null +++ b/backend/promote_super_admin.py @@ -0,0 +1,40 @@ +import argparse +import sys + +from app.services.auth_service import get_user_by_username +from app.services.db import db_connection + + +def promote_user(email: str) -> int: + user = get_user_by_username(email) + if not user: + print(f"User not found: {email}", file=sys.stderr) + return 1 + + with db_connection() as conn: + with conn: + with conn.cursor() as cur: + cur.execute( + """ + UPDATE app_user + SET role = 'SUPER_ADMIN', + is_admin = TRUE, + is_super_admin = TRUE + WHERE id = %s + """, + (user["id"],), + ) + + print(f"Promoted {email} to SUPER_ADMIN") + return 0 + + +def main() -> int: + parser = argparse.ArgumentParser(description="Promote an existing user to SUPER_ADMIN.") + parser.add_argument("email", help="User email to promote") + args = parser.parse_args() + return promote_user(args.email.strip()) + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/backend/run_backend.ps1 b/backend/run_backend.ps1 index f67f51a..de0097e 100644 --- a/backend/run_backend.ps1 +++ b/backend/run_backend.ps1 @@ -18,7 +18,7 @@ if (Test-Path $frontendUrlFile) { } } if (-not $env:BROKER_TOKEN_KEY) { $env:BROKER_TOKEN_KEY = '6SuYLz0n7-KM5nB_Bs6ueYgDXZZvbmf-K-WpFbOMbH4=' } -if (-not $env:SUPER_ADMIN_EMAIL) { $env:SUPER_ADMIN_EMAIL = 'admin@example.com' } +if (-not $env:SUPER_ADMIN_EMAIL) { $env:SUPER_ADMIN_EMAIL = 'thigazhezhilanj007@gmail.com' } if (-not $env:SUPER_ADMIN_PASSWORD) { $env:SUPER_ADMIN_PASSWORD = 'AdminPass123!' } if (-not $env:SMTP_HOST) { $env:SMTP_HOST = 'smtp.gmail.com' } if (-not $env:SMTP_PORT) { $env:SMTP_PORT = '587' }