Fix the problem of creating PAT with hidden roles (#4800)

#### What type of PR is this?

/kind bug
/area core
/milestone 2.11.x

#### What this PR does / why we need it:

Fix the problem that we will encounter "insufficient roles" error while creating PAT with hidden roles.

#### Which issue(s) this PR fixes:

Fixes https://github.com/halo-dev/halo/issues/4783

#### Does this PR introduce a user-facing change?

```release-note
修复因部分角色导致无法正常创建个人令牌的问题
```
pull/4804/head^2
John Niang 2023-10-31 22:00:09 -05:00 committed by GitHub
parent f2d7376d9f
commit dcf099691f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -54,7 +54,7 @@ public class DefaultRoleService implements RoleService {
if (source.contains(SuperAdminInitializer.SUPER_ROLE_NAME)) {
return Mono.just(true);
}
return listDependencies(new HashSet<>(source), shouldFilterHidden(true))
return listDependencies(new HashSet<>(source), shouldFilterHidden(false))
.map(role -> role.getMetadata().getName())
.collect(Collectors.toSet())
.map(roleNames -> roleNames.containsAll(candidates));