local bcrypt = require("bcrypt") local models = require("models") local constants = require("constants") local alphabet = "-_@0123456789abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVWXYZ" local function create_admin() local username = "admin" local root_count = models.Users:count("username = ?", username) if root_count ~= 0 then print("admin account already exists.") return end local password = "" for _ = 1, 16 do local randi = math.random(#alphabet) password = password .. alphabet:sub(randi, randi) end local hash = bcrypt.digest(password, constants.BCRYPT_ROUNDS) models.Users:create({ username = username, password_hash = hash, permission = constants.PermissionLevel.ADMIN, }) print("Admin account created, use \"admin\" as the login and \"" .. password .. "\" as the password. This will only be shown once.") end local function create_deleted_user() local username = "DeletedUser" local root_count = models.Users:count("username = ?", username) if root_count ~= 0 then print("deleted user already exists") return end models.Users:create({ username = username, password_hash = "", permission = constants.PermissionLevel.SYSTEM, }) end create_admin() create_deleted_user()