-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCheck-auth.vue
27 lines (26 loc) · 882 Bytes
/
Check-auth.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<script>
import router from 'router'
import { ADD_MESSAGE_MUTATION } from 'store/message/mutations'
import { mapState } from 'vuex'
export default {
//if already trying to login
created() {
if (this.failedLogin) {
router.push({ path: '/' })
this.$store.commit('Message/' + ADD_MESSAGE_MUTATION, 'You are not authorized')
}
},
computed: mapState({
failedLogin: state => state.User.failedLogin,
}),
watch: {
//wait initial login after page loading
failedLogin: function (failedLogin) {
if (failedLogin) {
router.push({ path: '/' })
this.$store.commit('Message/' + ADD_MESSAGE_MUTATION, 'You are not authorized')
}
},
},
}
</script>