chore: check off Task 4 (Auth module integration)

This commit is contained in:
2026-07-02 11:38:07 +08:00
parent 80ff225e92
commit 9051497704
2 changed files with 8 additions and 8 deletions

View File

@@ -759,7 +759,7 @@ git commit -m "feat(rbac): add PermissionGuard, @Public and @RequirePermission d
- Consumes: `RbacService.getUserPermissions(userId)` (from Task 2)
- Produces: login 返回 `{ access_token, user: { id, username, name, roles, permissions } }`, JWT payload 包含 `{ sub, username, permissions }`
- [ ] **Step 1: 修改 AuthModule 导入 RbacModule**
- [x] **Step 1: 修改 AuthModule 导入 RbacModule**
```typescript
// backend/src/auth/auth.module.ts
@@ -797,7 +797,7 @@ export class AuthModule {}
注意:移除 `OnModuleInit` 实现,`initAdmin` 已迁移至 `RbacModule`
- [ ] **Step 2: 修改 AuthService.login() 集成权限查询**
- [x] **Step 2: 修改 AuthService.login() 集成权限查询**
`backend/src/auth/auth.service.ts` 中:
@@ -891,7 +891,7 @@ export class AuthService {
保留 `validateUser()`(供 JwtStrategy 使用)和 `recordFailedAttempt()`(私有)。
- [ ] **Step 3: 修改 AuthController**
- [x] **Step 3: 修改 AuthController**
`backend/src/auth/auth.controller.ts` 中:
@@ -948,7 +948,7 @@ export class AuthController {
- `PUT /auth/users/:id/password` → 迁移至 `/rbac/users/:id/password PUT`
- `DELETE /auth/users/:id` → 迁移至 `/rbac/users/:id DELETE`
- [ ] **Step 4: 修改 JwtStrategy**
- [x] **Step 4: 修改 JwtStrategy**
```typescript
// backend/src/auth/strategies/jwt.strategy.ts
@@ -977,7 +977,7 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
}
```
- [ ] **Step 5: 编译验证**
- [x] **Step 5: 编译验证**
```bash
cd backend && npx tsc --noEmit
@@ -985,7 +985,7 @@ cd backend && npx tsc --noEmit
预期:无类型错误。如有循环依赖错误,确认 `forwardRef` 已正确配置。
- [ ] **Step 6: Commit**
- [x] **Step 6: Commit**
```bash
git add backend/src/auth/

View File

@@ -19,8 +19,8 @@
- [x] 3.1 创建 @RequirePermission 装饰器(支持 AND/OR 语义,通过 SetMetadata 存储权限列表和逻辑模式)
- [x] 3.2 创建 PermissionGuard从 JWT payload 中读取 permissions 数组,与装饰器标注的权限做匹配
- [ ] 3.3 修改 JwtStrategy 和 AuthService.login登录时调用 getUserPermissions将 permissions 写入 JWT payload
- [ ] 3.4 修改 AuthService.validateUser/profile返回用户信息时携带角色和权限列表
- [x] 3.3 修改 JwtStrategy 和 AuthService.login登录时调用 getUserPermissions将 permissions 写入 JWT payload
- [x] 3.4 修改 AuthService.validateUser/profile返回用户信息时携带角色和权限列表
- [ ] 3.5 全局注册 PermissionGuard或在各模块按需注册
## 4. 现有接口批量加守卫