I use vue-authenticate (https://github.com/dgrubelic/vue-authenticate) to login with ID/Password and Oauth 1 & 2.
Where I put the router redirect to redirect user on dashboard page?
this.$router.push({name: 'dashboard'})
My code store.js with Vuex:
import Vue from 'vue'
import Vuex from 'vuex'
import {vueAuth} from './auth'
Vue.use(Vuex)
export default new Vuex.Store({
state: {
isAuthenticated: false
},
getters: {
isAuthenticated () {
return vueAuth.isAuthenticated()
}
},
mutations: {
isAuthenticated (state, payload) {
state.isAuthenticated = payload.isAuthenticated
},
setProfile (state, payload) {
state.profile = payload.profile
}
},
actions: {
login (context, payload) {
payload = payload || {}
return vueAuth.login(payload.user, payload.requestOptions).then((response) => {
context.commit('isAuthenticated', {
isAuthenticated: vueAuth.isAuthenticated()
})
})
}
}
})