We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f50dc89 commit 62d03f0Copy full SHA for 62d03f0
src/http/auth.ts
@@ -84,11 +84,16 @@ export abstract class CognitoAuthorizer {
84
}
85
86
87
+ public getGroups(): string[] {
88
+ if (!this.isAuthenticated() || !this.claims!.hasOwnProperty('cognito:groups')) {
89
+ return [];
90
+ }
91
+ return this.claims!['cognito:groups'] as unknown as string[];
92
93
+
94
public hasGroup(group: string): boolean {
95
// 'cognito:groups': [ 'admin' ],
- return this.isAuthenticated()
- && this.claims!.hasOwnProperty('cognito:groups')
- && (this.claims!['cognito:groups'] as unknown as string[]).includes(group);
96
+ return this.getGroups().includes(group);
97
98
99
public assertGroup(group: string): void {
0 commit comments