diff --git a/src/js/app.js b/src/js/app.js index c3c6739..da25fcb 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -68,9 +68,6 @@ var app = new Framework7({ cordovaApp.init(f7); } - // Retrieve data for user on app start - user.dispatch('checkData').then(() =>{ }); - //Intercept axios call to determine if it gets (401 Unauthorized) response http.interceptors.response.use(undefined, function (err) { return new Promise(function (resolve, reject) { diff --git a/src/js/controllers/check.js b/src/js/controllers/check.js index 0130b5e..a89e1e9 100644 --- a/src/js/controllers/check.js +++ b/src/js/controllers/check.js @@ -1,8 +1,9 @@ import user from './../stores/user.js'; let Check = { - authorization( { to, resolve } ) { + async authorization( { to, resolve } ) { const router = this; + await user.dispatch('checkData'); if (!user.getters.isLogged.value){ router.navigate('/login/', { reloadCurrent: true }); } diff --git a/src/js/routes.js b/src/js/routes.js index 1a9423a..4fedf16 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -12,8 +12,6 @@ let routes = [ name: 'about', path: '/about/', component: AboutPage, - allowedRoles: [15], - beforeEnter: [Check.authorization, Check.permission], }, ...home, ...login, diff --git a/src/js/routes/home.js b/src/js/routes/home.js index 45c5647..ff4e67e 100644 --- a/src/js/routes/home.js +++ b/src/js/routes/home.js @@ -2,11 +2,15 @@ import HomePage from '../../pages/home.f7.html'; import LeftPanelPage from '../../pages/home/panel-left.f7.html'; import RightPanelPage from '../../pages/home/panel-right.f7.html'; +import Check from './../controllers/check'; + const home = [ { name: 'home', path: '/', component: HomePage, + allowedRoles: [1,9,10,14,15], + beforeEnter: [Check.authorization, Check.permission], }, { name: 'panel-left-',