ZeroNinerOne commited on
Commit
2e22acc
·
verified ·
1 Parent(s): 2cf931a

Upload make_admin.py

Browse files
Files changed (1) hide show
  1. make_admin.py +26 -0
make_admin.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Run this once to grant admin access to your account:
3
+ python make_admin.py YOUR_USERNAME
4
+
5
+ On HuggingFace — add this as a startup command or run it via the Space terminal.
6
+ """
7
+ import sys, os
8
+ os.environ.setdefault("NEUROCHECK_DB", "neurocheck.db")
9
+
10
+ from api.database import init_db, set_admin, migrate_add_admin_column, get_user_by_username
11
+
12
+ username = sys.argv[1] if len(sys.argv) > 1 else os.environ.get("ADMIN_USERNAME", "")
13
+ if not username:
14
+ print("Usage: python make_admin.py YOUR_USERNAME")
15
+ sys.exit(1)
16
+
17
+ init_db()
18
+ migrate_add_admin_column()
19
+
20
+ user = get_user_by_username(username)
21
+ if not user:
22
+ print(f"User '{username}' not found. Register first at /chat-ui then run this.")
23
+ sys.exit(1)
24
+
25
+ ok = set_admin(username, True)
26
+ print(f"{'✅' if ok else '❌'} Admin access {'granted to' if ok else 'failed for'} '{username}'")