-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_admin.py
More file actions
45 lines (35 loc) · 1.48 KB
/
Copy pathcreate_admin.py
File metadata and controls
45 lines (35 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# create_admin.py
"""
Create an admin or reviewer account for the AEDIS Review Center.
Usage:
python create_admin.py admin@yourdomain.com YourStrongPassword "Your Name"
python create_admin.py reviewer@yourdomain.com Pass123456 "Reviewer Name" reviewer
The fourth argument (account type) defaults to 'admin'. Valid types:
admin Full access - approve applications, issue AEDIS IDs, suspend.
reviewer Can view the queue and request documents; cannot approve.
Admin accounts can only be created from this script (i.e. by whoever has
shell access to the machine AEDIS runs on) - the public /api/auth/register
endpoint always creates plain registrant accounts. That is the entire
privilege model for a local install: control of the box = admin.
"""
import sys
from app import app
from extensions import db
import aedis_auth as auth
def main():
if len(sys.argv) < 4:
print(__doc__)
sys.exit(1)
email, password, full_name = sys.argv[1], sys.argv[2], sys.argv[3]
account_type = sys.argv[4] if len(sys.argv) > 4 else "admin"
with app.app_context():
db.create_all()
try:
account = auth.create_account(email, password, full_name, account_type)
print(f"Created {account.account_type} account: {account.email} ({account.full_name})")
print(f"Sign in at http://localhost:5000/admin")
except ValueError as e:
print(f"Error: {e}")
sys.exit(1)
if __name__ == "__main__":
main()