update of an outadet approach of the user adding in the current version
This commit is contained in:
+3
-43
@@ -206,50 +206,10 @@ import Web.modules.database.user as us
|
|||||||
tenant_id = sys.argv[1].lower()
|
tenant_id = sys.argv[1].lower()
|
||||||
mode = sys.argv[2]
|
mode = sys.argv[2]
|
||||||
sanitized = "".join(c for c in tenant_id if c.isalnum() or c == "_")
|
sanitized = "".join(c for c in tenant_id if c.isalnum() or c == "_")
|
||||||
db_name = f"inventar_{sanitized}"
|
|
||||||
client = MongoClient(settings.MONGODB_HOST, int(settings.MONGODB_PORT))
|
|
||||||
db = client[db_name]
|
|
||||||
|
|
||||||
pw_bytes = "admin123".encode("utf-8")
|
us.add_user("admin", "admin123", "admin", "admin", permission_preset='full_access')
|
||||||
random_salt = os.urandom(16)
|
us.make_admin("admin")
|
||||||
hashed = hashlib.scrypt(pw_bytes, salt=random_salt, n=16384, r=8, p=1)
|
print("Fallback successfully applied")
|
||||||
hashed_pw_string = f"v1${random_salt.hex()}${hashed.hex()}"
|
|
||||||
|
|
||||||
action_permissions = {
|
|
||||||
"can_borrow": True,
|
|
||||||
"can_insert": True,
|
|
||||||
"can_edit": True,
|
|
||||||
"can_delete": True,
|
|
||||||
"can_manage_users": True,
|
|
||||||
"can_manage_settings": True,
|
|
||||||
"can_view_logs": True,
|
|
||||||
}
|
|
||||||
|
|
||||||
page_permissions = {
|
|
||||||
"home": True,
|
|
||||||
"tutorial_page": True,
|
|
||||||
"my_borrowed_items": True,
|
|
||||||
"notifications_view": True,
|
|
||||||
"impressum": True,
|
|
||||||
"license": True,
|
|
||||||
"library_view": True,
|
|
||||||
"terminplan": True,
|
|
||||||
"home_admin": True,
|
|
||||||
"upload_admin": True,
|
|
||||||
"library_admin": True,
|
|
||||||
"admin_borrowings": True,
|
|
||||||
"library_loans_admin": True,
|
|
||||||
"admin_damaged_items": True,
|
|
||||||
"admin_audit_dashboard": True,
|
|
||||||
"logs": True,
|
|
||||||
"manage_filters": True,
|
|
||||||
"manage_locations": True,
|
|
||||||
}
|
|
||||||
|
|
||||||
if db.users.count_documents({"Username": dp.encrypt_text("admin")}) == 0:
|
|
||||||
us.add_user("admin", "admin123", "admin", "admin", permission_preset='full_access')
|
|
||||||
us.make_admin("admin")
|
|
||||||
print("Fallback successfully applied")
|
|
||||||
|
|
||||||
if mode == "trial":
|
if mode == "trial":
|
||||||
db.settings.update_one(
|
db.settings.update_one(
|
||||||
|
|||||||
Reference in New Issue
Block a user