mirror of
https://github.com/mivodev/mivo.git
synced 2026-01-26 13:31:56 +07:00
feat: Implement an installation process including a setup UI, database migrations, and admin account creation.
This commit is contained in:
@@ -15,8 +15,12 @@ class InstallController extends Controller {
|
||||
header('Location: /login');
|
||||
exit;
|
||||
}
|
||||
|
||||
$permissions = $this->checkPermissions();
|
||||
|
||||
return $this->view('install');
|
||||
return $this->view('install', [
|
||||
'permissions' => $permissions
|
||||
]);
|
||||
}
|
||||
|
||||
public function process() {
|
||||
@@ -25,6 +29,13 @@ class InstallController extends Controller {
|
||||
exit;
|
||||
}
|
||||
|
||||
$permissions = $this->checkPermissions();
|
||||
if (!$permissions['db_writable'] || !$permissions['root_writable']) {
|
||||
\App\Helpers\FlashHelper::set('error', 'Izin Ditolak', 'Pastikan folder app/Database dan root direktori dapat ditulis oleh server web.');
|
||||
header('Location: /install');
|
||||
exit;
|
||||
}
|
||||
|
||||
$username = $_POST['username'] ?? 'admin';
|
||||
$password = $_POST['password'] ?? 'admin';
|
||||
|
||||
@@ -63,6 +74,17 @@ class InstallController extends Controller {
|
||||
}
|
||||
}
|
||||
|
||||
private function checkPermissions() {
|
||||
$dbDir = ROOT . '/app/Database';
|
||||
$envFile = ROOT . '/.env';
|
||||
|
||||
return [
|
||||
'db_writable' => is_writable($dbDir),
|
||||
'env_writable' => file_exists($envFile) ? is_writable($envFile) : is_writable(ROOT),
|
||||
'root_writable' => is_writable(ROOT)
|
||||
];
|
||||
}
|
||||
|
||||
private function isInstalled() {
|
||||
// Check if .env exists and APP_KEY is set to something other than the default/example
|
||||
$envPath = ROOT . '/.env';
|
||||
|
||||
Reference in New Issue
Block a user