Created
February 5, 2021 20:16
-
-
Save dabit3/b703e612e6f450251f79c345cda7a3f4 to your computer and use it in GitHub Desktop.
Checking for claims in the identity object - AppSync with Lambda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To man manually check for groups, you can get the user's identity from | |
// the event.identity object, and check for claims in | |
// the event.identity.claims['cognito:groups'] | |
function checkForGroup(event:AppSyncEvent, groupName:string) { | |
if (event.identity) { | |
if (event.identity.claims['cognito:groups']) { | |
if (event.identity.claims['cognito:groups'].includes(groupName)) { | |
return true | |
} | |
} | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment