Skip to content

Commit

Permalink
Merge pull request #244 from UnicornGlobal/any-role-routes
Browse files Browse the repository at this point in the history
Support "any role" routes
  • Loading branch information
darrynten authored Dec 18, 2019
2 parents 9bfd860 + 577c25d commit cf59407
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ This may change in the future but is the convention for now.
**NB** You *must* att `static:true` to the `meta` field of your static
routes. This may change in the future but is convention for now.

#### Allow Any Role

To allow any role on a route just set role to `false`

### Config Loading

The values in `/src/config/*.js` will be overridden by any values
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@unicorns/quick-dash-framework",
"version": "2.5.0",
"version": "2.5.1",
"description": "Quick Dashboard Framework",
"author": "Unicorn Global et al",
"license": "MIT",
Expand Down
4 changes: 4 additions & 0 deletions src/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ function filterRoutesByRole(routes, user) {
const processedRoutes = []

for (let i = 0; i < routes.length; i++) {
if (routes[i].role === false) {
processedRoutes.push(routes[i])
}

if (routes[i].role && userHasRole(user, routes[i].role)) {
processedRoutes.push(routes[i])
}
Expand Down

0 comments on commit cf59407

Please sign in to comment.