refactor(admin): 合并管理后台并移除 apps/agent

- 平台与代理共用 apps/admin,统一登录 manage/auth/login
- 按 userType 展示菜单,修复 token 循环跳转
- 删除独立 apps/agent 前端工程

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-02 17:50:58 +08:00
parent b5dca1bfb1
commit 31737286b9
34 changed files with 363 additions and 255 deletions

View File

@@ -32,6 +32,13 @@ export class AuthController {
return jsonResponse(result);
}
@Public()
@Post('manage/auth/login')
async manageLogin(@Body() dto: LoginDto) {
const result = await this.auth.staffLogin(dto.username, dto.password);
return jsonResponse(result);
}
@UseGuards(JwtAuthGuard)
@ApiBearerAuth()
@Post('player/auth/change-password')

View File

@@ -22,6 +22,19 @@ export class AuthService {
private config: ConfigService,
) {}
/** 平台管理员 / 代理统一登录(按 userType 签发对应 JWT */
async staffLogin(username: string, password: string) {
const user = await this.prisma.user.findUnique({
where: { username },
select: { userType: true },
});
if (!user || (user.userType !== 'ADMIN' && user.userType !== 'AGENT')) {
throw new UnauthorizedException('Invalid credentials');
}
const portal = user.userType === 'ADMIN' ? 'admin' : 'agent';
return this.login(username, password, portal);
}
async login(username: string, password: string, portal: 'player' | 'admin' | 'agent') {
const user = await this.prisma.user.findUnique({
where: { username },