Files
24kycj 152228d41f 前端配置迁至 config/local.js,完善支付、模板库与部署脚本
- 页面直接引用 local.js 设置 SOON_DEPLOY_CONFIG,移除 deploy-config
- Docker sync-config 生成 local.js;更新 README 与 agent-core 说明
- 模板库自动扫描 .soon;新增后端部署/种子/排查脚本
- 完善支付配置、订阅弹窗与后台支付管理页

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-08 20:48:51 +08:00

60 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
/**
* 创建或重置管理员(CLI,读取 config/local.php)。
* 用法: cd backend-web根目录 && php scripts/seed-admin.php [email] [password]
*/
if (PHP_SAPI !== 'cli') {
fwrite(STDERR, "CLI only\n");
exit(1);
}
require dirname(__DIR__) . '/src/bootstrap.php';
use Soon\Api\Core\Db;
$email = trim((string)($argv[1] ?? getenv('SOON_ADMIN_EMAIL') ?: 'admin@cardsoon.com'));
$plain = (string)($argv[2] ?? getenv('SOON_ADMIN_PASS') ?: 'cardsoon');
if ($email === '' || $plain === '') {
fwrite(STDERR, "usage: php scripts/seed-admin.php [email] [password]\n");
exit(1);
}
$pdo = Db::pdo();
$hash = password_hash($plain, PASSWORD_BCRYPT, ['cost' => 12]);
$now = date('Y-m-d H:i:s');
$stmt = $pdo->prepare('SELECT id FROM users WHERE email = :email LIMIT 1');
$stmt->execute(['email' => $email]);
$id = $stmt->fetchColumn();
if ($id) {
$pdo->prepare(
'UPDATE users SET password_hash = :h, role = :role, admin_level = :level, status = :status WHERE id = :id'
)->execute([
'h' => $hash,
'role' => 'admin',
'level' => 'full',
'status' => 'active',
'id' => (int)$id,
]);
fwrite(STDOUT, "OK updated admin #{$id} {$email}\n");
exit(0);
}
$pdo->prepare(
'INSERT INTO users (email, password_hash, role, admin_level, status, created_at) '
. 'VALUES (:email, :h, :role, :level, :status, :created_at)'
)->execute([
'email' => $email,
'h' => $hash,
'role' => 'admin',
'level' => 'full',
'status' => 'active',
'created_at' => $now,
]);
fwrite(STDOUT, "OK created admin {$email}\n");