mirror of
https://codeberg.org/yeentown/barkey
synced 2024-11-25 14:05:14 +00:00
コンディショナルロールもバッジとして表示可能に
This commit is contained in:
parent
7b29e36d64
commit
9351fb9617
2 changed files with 17 additions and 2 deletions
|
@ -8,6 +8,15 @@
|
||||||
|
|
||||||
You should also include the user name that made the change.
|
You should also include the user name that made the change.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
## 13.x.x (unreleased)
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
- コンディショナルロールもバッジとして表示可能に
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
-
|
||||||
|
|
||||||
## 13.5.6 (2023/02/10)
|
## 13.5.6 (2023/02/10)
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|
|
@ -211,9 +211,15 @@ export class RoleService implements OnApplicationShutdown {
|
||||||
const assignedRoleIds = assigns.map(x => x.roleId);
|
const assignedRoleIds = assigns.map(x => x.roleId);
|
||||||
const roles = await this.rolesCache.fetch(null, () => this.rolesRepository.findBy({}));
|
const roles = await this.rolesCache.fetch(null, () => this.rolesRepository.findBy({}));
|
||||||
const assignedBadgeRoles = roles.filter(r => r.asBadge && assignedRoleIds.includes(r.id));
|
const assignedBadgeRoles = roles.filter(r => r.asBadge && assignedRoleIds.includes(r.id));
|
||||||
// コンディショナルロールも含めるのは負荷高そうだから一旦無し
|
const badgeCondRoles = roles.filter(r => r.asBadge && (r.target === 'conditional'));
|
||||||
|
if (badgeCondRoles.length > 0) {
|
||||||
|
const user = roles.some(r => r.target === 'conditional') ? await this.userCacheService.findById(userId) : null;
|
||||||
|
const matchedBadgeCondRoles = badgeCondRoles.filter(r => this.evalCond(user!, r.condFormula));
|
||||||
|
return [...assignedBadgeRoles, ...matchedBadgeCondRoles];
|
||||||
|
} else {
|
||||||
return assignedBadgeRoles;
|
return assignedBadgeRoles;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@bindThis
|
@bindThis
|
||||||
public async getUserPolicies(userId: User['id'] | null): Promise<RolePolicies> {
|
public async getUserPolicies(userId: User['id'] | null): Promise<RolePolicies> {
|
||||||
|
|
Loading…
Reference in a new issue