Skip to content

Commit

Permalink
Merge pull request #220 from aziiee/dynamic-groups
Browse files Browse the repository at this point in the history
fix(permissions): allow dynamic group names
  • Loading branch information
Akanksh Saxena authored Dec 16, 2021
2 parents 800f434 + 65470fd commit 5c139ff
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/app/services/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@ export default class AccountService extends Service {
return this.session.data.authenticated?.userinfo.groups ?? [];
}

isInGroup(group) {
return this.groups.includes(group);
isInGroup(groupRegex) {
return this.groups.some((group) => new RegExp(groupRegex).test(group));
}

isInGroups(amount, groups) {
isInGroups(amount, groupsRegex) {
const method = amount === "one" ? "some" : "every";
return this.groups[method]((group) => groups.includes(group));
return this.groups[method]((group) =>
groupsRegex.some((groupRegex) => new RegExp(groupRegex).test(group))
);
}

async fetchCurrentUser() {
Expand Down

0 comments on commit 5c139ff

Please sign in to comment.