From dc8c32e6789c4029cb7040a33331cbe0fab8b6e9 Mon Sep 17 00:00:00 2001 From: walkor Date: Tue, 7 Mar 2023 12:42:33 +0800 Subject: [PATCH] Update InstallController.php --- src/plugin/admin/app/controller/InstallController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/plugin/admin/app/controller/InstallController.php b/src/plugin/admin/app/controller/InstallController.php index a6fcf8b..d62caa1 100644 --- a/src/plugin/admin/app/controller/InstallController.php +++ b/src/plugin/admin/app/controller/InstallController.php @@ -198,15 +198,17 @@ EOF; if ($password != $password_confirm) { return $this->json(1, '两次密码不一致'); } - if (Admin::first()) { - return $this->json(1, '后台已经安装完毕,无法通过此页面创建管理员'); - } if (!is_file($config_file = base_path() . '/plugin/admin/config/database.php')) { return $this->json(1, '请先完成第一步数据库配置'); } $config = include $config_file; $connection = $config['connections']['mysql']; $pdo = $this->getPdo($connection['host'], $connection['username'], $connection['password'], $connection['port'], $connection['database']); + + if ($pdo->query('select * from `wa_admins`')->fetchAll()) { + return $this->json(1, '后台已经安装完毕,无法通过此页面创建管理员'); + } + $smt = $pdo->prepare("insert into `wa_admins` (`username`, `password`, `nickname`, `created_at`, `updated_at`) values (:username, :password, :nickname, :created_at, :updated_at)"); $time = date('Y-m-d H:i:s'); $data = [