redirect to logout

This commit is contained in:
Moriz Wahl 2021-12-07 19:14:54 +01:00
parent 3fff3cce67
commit 811c240679
2 changed files with 6 additions and 6 deletions

View File

@ -18,7 +18,7 @@ const authLink = new ApolloLink((operation, forward) => {
if (response.errors && response.errors[0].message === '403.13 - Client certificate revoked') {
response.errors[0].message = i18n.t('error.session-expired')
store.dispatch('logout', null)
if (router.currentRoute.path !== '/login') router.push('/login')
if (router.currentRoute.path !== '/logout') router.push('/logout')
return response
}
const newToken = operation.getContext().response.headers.get('token')

View File

@ -128,19 +128,19 @@ describe('apolloProvider', () => {
expect(storeDispatchMock).toBeCalledWith('logout', null)
})
describe('current route is not login', () => {
describe('current route is not logout', () => {
it('redirects to logout', () => {
expect(routerPushMock).toBeCalledWith('/login')
expect(routerPushMock).toBeCalledWith('/logout')
})
})
describe('current route is login', () => {
describe('current route is logout', () => {
beforeEach(() => {
jest.clearAllMocks()
router.currentRoute.path = '/login'
router.currentRoute.path = '/logout'
})
it('does not redirect to login', () => {
it('does not redirect to logout', () => {
expect(routerPushMock).not.toBeCalled()
})
})