@oniti/quasar-app-extension-vlank-auth 3.2.2 → 3.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/package.json +1 -1
- package/src/boot/index.js +4 -2
package/README.md
CHANGED
|
@@ -47,19 +47,34 @@ chainWebpack(chain) {
|
|
|
47
47
|
}
|
|
48
48
|
```
|
|
49
49
|
### Configuration Optional
|
|
50
|
+
You can define a custom function to check route access.
|
|
51
|
+
|
|
52
|
+
in `quasar.conf.js`
|
|
50
53
|
```javascript
|
|
54
|
+
boot: [...,'override-check-route-access'],
|
|
55
|
+
...,
|
|
51
56
|
framework:{
|
|
52
57
|
...,
|
|
53
58
|
config:{
|
|
54
59
|
onitiVlankAuth: {
|
|
55
|
-
|
|
56
|
-
return false
|
|
57
|
-
}
|
|
60
|
+
check_route_access_overide_name: "$vlankAuthCheckAccessRoute"
|
|
58
61
|
},
|
|
59
62
|
...
|
|
60
63
|
}
|
|
61
64
|
}
|
|
62
65
|
```
|
|
66
|
+
`override-check-route-access.js`
|
|
67
|
+
```javascript
|
|
68
|
+
import { boot } from 'quasar/wrappers'
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
export default boot(({ app }) => {
|
|
72
|
+
app.config.globalProperties.$vlankAuthCheckAccessRoute = (user, to) => {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
```
|
|
77
|
+
|
|
63
78
|
### Usage
|
|
64
79
|
Just add requieresAuth as meta on route to require an auth.
|
|
65
80
|
|
package/package.json
CHANGED
package/src/boot/index.js
CHANGED
|
@@ -7,6 +7,7 @@ export default boot(({ app, router, store }) => {
|
|
|
7
7
|
store.registerModule("auth", auth);
|
|
8
8
|
|
|
9
9
|
const config = app.config.globalProperties.$q.config.onitiVlankAuth;
|
|
10
|
+
const configFramework = app.config.globalProperties.$q.config.onitiVlankAuthConfig ? app.config.globalProperties.$q.config.onitiVlankAuthConfig : {};
|
|
10
11
|
|
|
11
12
|
// Fonction permettant de géré la redirection en cas decompte non loggué
|
|
12
13
|
router.beforeEach((to, from, next) => {
|
|
@@ -42,7 +43,8 @@ export default boot(({ app, router, store }) => {
|
|
|
42
43
|
typeRightCheck = typeRightCheck ? typeRightCheck.meta.typeRightCheck : "all";
|
|
43
44
|
|
|
44
45
|
const getter_right_check = typeRightCheck === "any" ? "auth/checkAny" : "auth/checkAll";
|
|
45
|
-
const
|
|
46
|
+
const check_route_access_overide_name = configFramework.check_route_access_overide_name;
|
|
47
|
+
const check_route_access_overide = app.config.globalProperties[check_route_access_overide_name];
|
|
46
48
|
|
|
47
49
|
let logoutOnUnsufisantRights = to.matched.find((r) =>
|
|
48
50
|
r.meta.hasOwnProperty("logoutOnUnsufisantRights")
|
|
@@ -58,7 +60,7 @@ export default boot(({ app, router, store }) => {
|
|
|
58
60
|
// eslint-disable-next-line
|
|
59
61
|
if (store.getters["auth/isAuthenticated"]) {
|
|
60
62
|
// Pas les droits nécéssaires
|
|
61
|
-
if ((check_route_access_overide && check_route_access_overide(store.getters['user'],to)) || (!check_route_access_overide &&!store.getters[getter_right_check](rights))) {
|
|
63
|
+
if ((check_route_access_overide && !check_route_access_overide(store.getters['auth/user'],to)) || (!check_route_access_overide &&!store.getters[getter_right_check](rights))) {
|
|
62
64
|
if (logoutOnUnsufisantRights) {
|
|
63
65
|
store.dispatch("auth/logout");
|
|
64
66
|
next(helper.getLoginRoute());
|