-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage.py
More file actions
38 lines (31 loc) · 1.14 KB
/
manage.py
File metadata and controls
38 lines (31 loc) · 1.14 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
import argparse
from werkzeug.security import generate_password_hash
import secrets
import string
from modules.Auth.auth import auth
from modules.Auth.user_db import UserDatabase
from app import app
def main():
parser = argparse.ArgumentParser(description="Archive posters from impawards.com")
parser.add_argument("--init", help="Starting pages number", action="store_true")
args = parser.parse_args()
if args.init:
print(app.config["USERS_DB"])
db = UserDatabase(app.config["USERS_DB"])
resp = db.create_tables()
if resp:
print("Created database tables")
else:
print("Failed to insert database tables")
return False
alphabet = string.ascii_letters + string.digits
password = ''.join(secrets.choice(alphabet) for i in range(12))
resp = db.insert_user(
"admin", "admin", "user", "admin@ohas.com",
generate_password_hash(password, method="sha256"), "", 24, 1
)
if resp:
print(f"Inserted admin user with password {password}")
else:
print("Failed to insert admin user")
main()