Skip to content
Snippets Groups Projects
Commit 7460ad49 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Logout message on Login page after redirect #22

parent aba2c7f4
Branches
No related tags found
1 merge request!23Resolve "Logout of tutors after inactivity"
Pipeline #
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
type="password" type="password"
required required
></v-text-field> ></v-text-field>
<v-btn type="submit" color="primary">Access</v-btn> <v-btn :loading="loading" type="submit" color="primary">Access</v-btn>
</v-form> </v-form>
</v-flex> </v-flex>
</v-layout> </v-layout>
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<script> <script>
import {mapActions} from 'vuex' import {mapActions, mapState} from 'vuex'
export default { export default {
name: 'grady-login', name: 'grady-login',
data () { data () {
...@@ -44,9 +44,14 @@ ...@@ -44,9 +44,14 @@
username: '', username: '',
password: '' password: ''
}, },
error: '' loading: false
} }
}, },
computed: {
...mapState([
'error'
])
},
methods: { methods: {
...mapActions([ ...mapActions([
'getJWTToken', 'getJWTToken',
...@@ -55,14 +60,14 @@ ...@@ -55,14 +60,14 @@
'getJWTTimeDelta' 'getJWTTimeDelta'
]), ]),
submit () { submit () {
this.loading = true
this.getJWTToken(this.credentials).then(() => { this.getJWTToken(this.credentials).then(() => {
this.loading = false
this.$router.push('/student/') this.$router.push('/student/')
this.getExamModule() this.getExamModule()
this.getUserRole() this.getUserRole()
this.getJWTTimeDelta() this.getJWTTimeDelta()
}).catch(() => { }).catch(() => { this.loading = false })
this.error = this.$store.state.error
})
} }
} }
} }
......
...@@ -62,8 +62,11 @@ router.beforeEach((to, from, next) => { ...@@ -62,8 +62,11 @@ router.beforeEach((to, from, next) => {
next() next()
} else { } else {
const now = new Date() const now = new Date()
if (now - store.state.logInTime > store.state.jwtTimeDelta * 1000) { if (now - store.state.logInTime > store.state.jwtTimeDelta) {
store.dispatch('logout').then(() => next('/')) store.dispatch('logout').then(() => {
store.commit('API_FAIL', 'You\'ve been logged out due to inactivity')
next('/')
})
} else { } else {
store.dispatch('refreshJWTToken') store.dispatch('refreshJWTToken')
next() next()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment