mirror of
https://github.com/margrop/wrong-notebook.git
synced 2026-12-05 08:09:38 +08:00
- 服务启动时若还没有管理员,生成一次性令牌保存到配置目录的 setup-token,并在日志中打印 /initialize?token= 链接;已有管理员时删除残留令牌 - 新增 /initialize 页面与 POST /api/initialize:凭令牌设置管理员名称、邮箱和密码(不能用 123456),成功后自动登录进入安装向导;令牌改名占用,并发提交只会创建一个管理员 - 登录页在尚未创建管理员时说明各安装方式到哪里找初始化链接,注册状态接口增加 initialized - prisma/seed.ts、scripts/seed-admin.js 不再创建 admin@localhost,只为已有的默认管理员恢复角色;E2E 准备脚本改为创建测试管理员 - 已有实例升级保留原账号,旧默认管理员仍走强制改密流程 - 同步中英文 README、Wiki、安装包说明与 npm、飞牛OS 的首次使用提示 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
26 lines
814 B
TypeScript
26 lines
814 B
TypeScript
import { PrismaClient } from '@prisma/client';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
/**
|
||
* 全新安装不再创建固定密码的默认管理员:服务启动时会在日志中打印一次性初始化链接,
|
||
* 打开后设置管理员账号(见 src/lib/initialization.ts)。这里只提示当前状态。
|
||
*/
|
||
async function main() {
|
||
const admins = await prisma.user.count({ where: { role: 'admin' } });
|
||
if (admins > 0) {
|
||
console.log(`Found ${admins} admin user(s). Nothing to seed.`);
|
||
return;
|
||
}
|
||
console.log('No admin user yet. Start the server and open the one-time setup link printed in its log to create one.');
|
||
}
|
||
|
||
main()
|
||
.catch((e) => {
|
||
console.error(e);
|
||
process.exit(1);
|
||
})
|
||
.finally(async () => {
|
||
await prisma.$disconnect();
|
||
});
|