everythinginjs / strapi-plugin-update-static-content

An Strapi plugin for rebuilding and deploying your static website via Github Actions.
12 stars 6 forks source link

Fix permission checking #3

Closed iangabrielsanchez closed 1 year ago

iangabrielsanchez commented 1 year ago

The previous implementation has issues with role orders. Consider the following example: The config has the following permissions set:

['strapi-super-admin', 'strapi-editor']

And the user has the permissions:

['strapi-editor', 'strapi-author']

In the previous implementation, on the first iteration of adminRoles, it will set hasPermission to true and set it back to false on the second iteration. This PR fixes that so that it immediately returns on the first time it detects hasPermission is set to true which entirely skips all the remaining iterations. If hasPermission never becomes true, it just throws an error