Methods
# static getFirstGrantedRouteFromVueRoutes()
Given a list of vue routes (vue-router), returns the first route available for the current user (based access rights loaded on memory)
Note: Routes are sorted by meta.weight ASC. (i.g Location could have priority over Ecoconduite) Note: Login route is skip Note: Routes with meta.allowRedirect=false are skip
- To Do:
-
- Add unit-test (router.spec.js)
- Parameter should be a list of non-vue-object routes
- Use a sort polyfill (sort behaves differently in firefox)
# static hasRight(rights, code, loggedUsername)
Given a list of rights codes and a right code, decide whenever the logged user has the right or not.
- sabadmin skip validation
- url?rights=0 skip validation on non production environments
- url?add_rights=XX add rights (during evaluation) on non production environments
- url?remove_rights=xx remove rights (during evaluation) on non production environments
- comparision is case insensitive
Parameters:
| Name | Type | Description |
|---|---|---|
rights |
Array
|
List of rights codes |
code |
String
|
Right code |
loggedUsername |
String
|
Username of the logged user |
options.startsWith |
String
|
(Optional) Match rights partially |
# static isVueRouteGranted(vueRoute)
Given a vue route (vue-router), returns TRUE/FALSE if the user has the required access rights.
Parameters:
| Name | Type | Description |
|---|---|---|
vueRoute |
*
|