Created
December 28, 2018 13:32
-
-
Save nabiltntn/240be21aa6bcffead835acc8c4a846a4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // For resolvers that require authenticated users with ADMIN role | |
| export const isAdminResolver = (resolver, trackDetails) => | |
| isAuthenticated.createResolver((root, args, context) => { | |
| if (![Constants.UsersRolesToIds.ADMIN, Constants.UsersRolesToIds.SUPER_ADMIN] | |
| .includes(context.user.role)) { | |
| throw new Errors.ForbiddenError(); | |
| } | |
| return executeWithTracking(resolver, root, args, context, trackDetails); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment