Created
October 10, 2018 14:27
-
-
Save brunokunace/fecc0f48e32c39d3b87e78de8e1468d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Login from '../components/Login' | |
import LoginForm from '../components/LoginForm' | |
import LoginFormReset from '../components/LoginFormReset' | |
export default [ | |
{ | |
path: '/login', | |
component: Login, | |
meta: {free: true}, | |
children: [ | |
{ | |
path: '', | |
name: 'Login', | |
component: LoginForm | |
}, | |
{ | |
path: 'redefinir', | |
name: 'FormReset', | |
component: LoginFormReset | |
} | |
] | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import App from './App.vue' | |
import router from './router' | |
import store from './store' | |
import './registerServiceWorker' | |
import Buefy from 'buefy' | |
import 'buefy/lib/buefy.css' | |
import './utils/moment' | |
import * as filters from './filters' | |
Vue.config.productionTip = false | |
require('./assets/sass/main.scss') | |
Vue.use(Buefy, { defaultIconPack: 'fa' }) | |
Object.keys(filters).forEach(key => { | |
Vue.filter(key, filters[key]) | |
}) | |
new Vue({ | |
router, | |
store, | |
render: h => h(App) | |
}).$mount('#app') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Router from 'vue-router' | |
import beforeEach from '@/utils/beforeEach' | |
import Login from '@/domains/login/routes' | |
import Dashboard from '@/domains/dashboard/routes' | |
Vue.use(Router) | |
const router = new Router({ | |
routes: [ | |
{ | |
path: '/', | |
redirect: '/login' | |
}, | |
...Login, | |
...Dashboard | |
] | |
}) | |
router.beforeEach(beforeEach) | |
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
import login from '@/domains/login/store' | |
Vue.use(Vuex) | |
export default new Vuex.Store({ | |
modules: { | |
login | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import store from '@/store.js' | |
const beforeEach = (to, from, next) => { | |
store.dispatch('setAuth') | |
if (!to.matched.some(record => record.meta.free)) { | |
if (!store.getters.isAuthenticated) { | |
next({ | |
path: '/login', | |
query: { redirect: to.fullPath } | |
}) | |
} else { | |
next() | |
} | |
} else { | |
next() | |
} | |
} | |
export default beforeEach |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment