- JWT 引入 sid,单会话精确强退(sid 黑名单)与按用户踢全部(tokenVersion) - User 新增 lockedAt/lockReason,登录/刷新/守卫统一拒绝锁定 - sessions 模块:活跃会话列表 + 单会话强退;users 新增 lock/unlock/kick-sessions - 资源注册 + syncTenantResources 存量租户补齐脚本 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
31 lines
1.1 KiB
TypeScript
31 lines
1.1 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
||
import { PLATFORM_ROLE_CODE, PLATFORM_TENANT_CODE, TENANT_ADMIN_ROLE_CODE } from '../src/common/constants.js';
|
||
import { syncTenantResources } from '../src/common/tenant-template.js';
|
||
|
||
const prisma = new PrismaClient();
|
||
|
||
/** 为所有存量租户补齐资源/字典/授权(幂等;不触碰用户/密码)。 */
|
||
async function main(): Promise<void> {
|
||
const tenants = await prisma.tenant.findMany({ select: { code: true } });
|
||
for (const t of tenants) {
|
||
const isPlatform = t.code === PLATFORM_TENANT_CODE;
|
||
await syncTenantResources({
|
||
prisma,
|
||
tenantCode: t.code,
|
||
adminRoleCode: isPlatform ? PLATFORM_ROLE_CODE : TENANT_ADMIN_ROLE_CODE,
|
||
includePlatformPerms: isPlatform,
|
||
});
|
||
console.log(`已同步资源:${t.code}(${isPlatform ? '平台' : '业务'}租户)`);
|
||
}
|
||
console.log(`syncTenantResources 完成,共 ${tenants.length} 个租户。`);
|
||
}
|
||
|
||
main()
|
||
.catch((e) => {
|
||
console.error(e);
|
||
process.exit(1);
|
||
})
|
||
.finally(async () => {
|
||
await prisma.$disconnect();
|
||
});
|