Reputation: 93
I am working on Amplify + React fullstack app and have created complete Authentication flow. I want to authorize users based on their roles i.e. admin, superadmin, user, etc. When I sign up a new user, I am seeing the details in AWS Cognito but I am not able to figure out the roles for the user. I have two solutions in mind.
I want to know which solution is better. I am unable to find any help online so it would be great if the detailed steps are shared. Thanks in advance.
Upvotes: 1
Views: 825
Reputation: 163
cognito groups are meant for exact same use cases. you can create a group named ADMIN and in your client you may check if the signed in user is part of ADMIN group like this
user.signInUserSession.accessToken.payload["cognito:groups"]?.includes("ADMIN")
Upvotes: 2