Skip to content

Instantly share code, notes, and snippets.

@dabit3
Created February 5, 2021 20:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabit3/b703e612e6f450251f79c345cda7a3f4 to your computer and use it in GitHub Desktop.
Save dabit3/b703e612e6f450251f79c345cda7a3f4 to your computer and use it in GitHub Desktop.
Checking for claims in the identity object - AppSync with Lambda
// 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