Merge branch 'master' into docu-env-vars

This commit is contained in:
Moriz Wahl 2022-07-14 18:39:21 +02:00 committed by GitHub
commit 46650133b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -62,12 +62,16 @@ describe('SessionLogoutTimeout', () => {
})
})
describe('token is expired', () => {
describe('token is expired for several seconds', () => {
beforeEach(() => {
mocks.$store.state.tokenTime = setTokenTime(-60)
wrapper = Wrapper()
})
it('has value for remaining seconds equal 0', () => {
expect(wrapper.tokenExpiresInSeconds === 0)
})
it('emits logout', () => {
expect(wrapper.emitted('logout')).toBeTruthy()
})

View File

@ -65,7 +65,7 @@ export default {
this.$timer.restart('tokenExpires')
this.$bvModal.show('modalSessionTimeOut')
}
if (this.tokenExpiresInSeconds <= 0) {
if (this.tokenExpiresInSeconds === 0) {
this.$timer.stop('tokenExpires')
this.$emit('logout')
}
@ -90,7 +90,10 @@ export default {
},
computed: {
tokenExpiresInSeconds() {
return Math.floor((new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000)
const remainingSecs = Math.floor(
(new Date(this.$store.state.tokenTime * 1000).getTime() - this.now) / 1000,
)
return remainingSecs <= 0 ? 0 : remainingSecs
},
},
beforeDestroy() {