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