This commit is contained in:
Tony 2024-09-03 16:04:47 +08:00
parent 56f70c5337
commit d8de82efca

View File

@ -21,7 +21,7 @@ const matchRole: (role: string, userRole: string) => boolean = (
if (!role) return true; if (!role) return true;
// 如果是超级管理员或者管理员,则返回 true // 如果是超级管理员或者管理员,则返回 true
if (userRole === 'admin') return; if (userRole === 'admin') return true;
return false; return false;
}; };
@ -37,8 +37,8 @@ export class RolesGuard implements CanActivate {
context.getHandler(), context.getHandler(),
context.getClass(), context.getClass(),
]); ]);
if (isPublic) return; if (isPublic) return true;
const role = this.reflector.get<string>('role', context.getHandler()); const role = this.reflector.get<string>('role', context.getHandler());