admin_page
This commit is contained in:
parent
f0353eddbc
commit
5f29d8c757
@ -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"
|
||||
}
|
||||
|
||||
40
backend/promote_super_admin.py
Normal file
40
backend/promote_super_admin.py
Normal file
@ -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())
|
||||
@ -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' }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user