Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions FINAL_PRODUCTION_SYSTEM/database/create_admin.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?php
require __DIR__ . '/../config.php';
$hash = password_hash("Admin2024!", PASSWORD_BCRYPT, ["cost" => 10]);
$stmt = $pdo->prepare("INSERT INTO admin_users (username, password_hash, full_name, email, role) VALUES (?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE password_hash = VALUES(password_hash), failed_login_attempts = 0, locked_until = NULL");
$stmt->execute(["admin", $hash, "Administrator", "admin@localhost", "super_admin"]);
// Get super_admin role ID from acl_roles
$roleId = $pdo->query("SELECT id FROM acl_roles WHERE role_name = 'super_admin' LIMIT 1")->fetchColumn() ?: null;

$stmt = $pdo->prepare("INSERT INTO admin_users (username, password_hash, full_name, email, role, custom_role_id) VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE password_hash = VALUES(password_hash), custom_role_id = VALUES(custom_role_id), failed_login_attempts = 0, locked_until = NULL");
$stmt->execute(["admin", $hash, "Administrator", "admin@localhost", "super_admin", $roleId]);
echo "Admin user created/reset\n";
Loading