Merge pull request #914 from gradido/fix-double-redirect-after-logout

fix: Double Redirect After Logout with Expired JWT
This commit is contained in:
Moriz Wahl 2021-10-01 12:08:41 +02:00 committed by GitHub
commit b5dc6742e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 12 deletions

View File

@ -32,6 +32,9 @@ describe('DashboardLayoutGdd', () => {
},
$router: {
push: routerPushMock,
currentRoute: {
path: '/overview',
},
},
$toasted: {
error: toasterMock,
@ -143,21 +146,23 @@ describe('DashboardLayoutGdd', () => {
it('redirects to login page', () => {
expect(routerPushMock).toBeCalledWith('/login')
})
})
describe('logout fails', () => {
beforeEach(() => {
apolloMock.mockRejectedValue({
message: 'error',
})
describe('logout fails', () => {
beforeEach(async () => {
apolloMock.mockRejectedValue({
message: 'error',
})
await wrapper.findComponent({ name: 'sidebar' }).vm.$emit('logout')
await flushPromises()
})
it('dispatches logout to store', () => {
expect(storeDispatchMock).toBeCalledWith('logout')
})
it('dispatches logout to store', () => {
expect(storeDispatchMock).toBeCalledWith('logout')
})
it('redirects to login page', () => {
expect(routerPushMock).toBeCalledWith('/login')
})
it('redirects to login page', () => {
expect(routerPushMock).toBeCalledWith('/login')
})
})

View File

@ -101,7 +101,7 @@ export default {
.catch(() => {
this.$sidebar.displaySidebar(false)
this.$store.dispatch('logout')
this.$router.push('/login')
if (this.$router.currentRoute.path !== '/login') this.$router.push('/login')
})
},
async updateTransactions(pagination) {