From a3682a424ecea5343a12acd1ac0afea4c0b68c59 Mon Sep 17 00:00:00 2001 From: elweyn Date: Wed, 12 Jan 2022 11:52:30 +0100 Subject: [PATCH 1/3] Fix redirect to /logout, now redirects to the wallet login. --- admin/src/plugins/apolloProvider.js | 3 +-- admin/src/plugins/apolloProvider.test.js | 14 +++++++------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/admin/src/plugins/apolloProvider.js b/admin/src/plugins/apolloProvider.js index 0e342b8fc..cde5408da 100644 --- a/admin/src/plugins/apolloProvider.js +++ b/admin/src/plugins/apolloProvider.js @@ -2,7 +2,6 @@ import { ApolloClient, ApolloLink, InMemoryCache, HttpLink } from 'apollo-boost' import VueApollo from 'vue-apollo' import CONFIG from '../config' import store from '../store/store' -import router from '../router/router' import i18n from '../i18n' const httpLink = new HttpLink({ uri: CONFIG.GRAPHQL_URI }) @@ -18,7 +17,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 !== '/logout') router.push('/logout') + window.location.assign(CONFIG.WALLET_URL) return response } const newToken = operation.getContext().response.headers.get('token') diff --git a/admin/src/plugins/apolloProvider.test.js b/admin/src/plugins/apolloProvider.test.js index e5f394e96..ab8b01f28 100644 --- a/admin/src/plugins/apolloProvider.test.js +++ b/admin/src/plugins/apolloProvider.test.js @@ -66,6 +66,11 @@ describe('apolloProvider', () => { path: '/overview', } + const windowLocationMock = jest.fn() + delete window.location + window.location = { + assign: windowLocationMock, + } // mock context const setContextMock = jest.fn() const getContextMock = jest.fn(() => { @@ -130,18 +135,13 @@ describe('apolloProvider', () => { describe('current route is not logout', () => { it('redirects to logout', () => { - expect(routerPushMock).toBeCalledWith('/logout') + expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') }) }) describe('current route is logout', () => { - beforeEach(() => { - jest.clearAllMocks() - router.currentRoute.path = '/logout' - }) - it('does not redirect to logout', () => { - expect(routerPushMock).not.toBeCalled() + expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') }) }) }) From 9d29c00ebbade58d71c0fd1a029a0b6f6c130322 Mon Sep 17 00:00:00 2001 From: elweyn Date: Thu, 13 Jan 2022 08:58:26 +0100 Subject: [PATCH 2/3] Remove route from apolloProvider.test and changed the test that checks the redirect on wallet login. --- admin/src/plugins/apolloProvider.test.js | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/admin/src/plugins/apolloProvider.test.js b/admin/src/plugins/apolloProvider.test.js index ab8b01f28..637efd1be 100644 --- a/admin/src/plugins/apolloProvider.test.js +++ b/admin/src/plugins/apolloProvider.test.js @@ -4,12 +4,10 @@ import CONFIG from '../config' import VueApollo from 'vue-apollo' import store from '../store/store' -import router from '../router/router' import i18n from '../i18n' jest.mock('vue-apollo') jest.mock('../store/store') -jest.mock('../router/router') jest.mock('../i18n') jest.mock('apollo-boost', () => { @@ -59,13 +57,6 @@ describe('apolloProvider', () => { errors: [{ message: '403.13 - Client certificate revoked' }], } - // mock router - const routerPushMock = jest.fn() - router.push = routerPushMock - router.currentRoute = { - path: '/overview', - } - const windowLocationMock = jest.fn() delete window.location window.location = { @@ -133,16 +124,8 @@ describe('apolloProvider', () => { expect(storeDispatchMock).toBeCalledWith('logout', null) }) - describe('current route is not logout', () => { - it('redirects to logout', () => { - expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') - }) - }) - - describe('current route is logout', () => { - it('does not redirect to logout', () => { - expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') - }) + it('redirects to logout', () => { + expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') }) }) From bea99f6904e9cae90fe9c17a9106e54a0b16bc76 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 14 Jan 2022 08:06:50 +0100 Subject: [PATCH 3/3] New login page is on localhost/login no vue anymore. --- admin/src/plugins/apolloProvider.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/plugins/apolloProvider.test.js b/admin/src/plugins/apolloProvider.test.js index 637efd1be..75e415901 100644 --- a/admin/src/plugins/apolloProvider.test.js +++ b/admin/src/plugins/apolloProvider.test.js @@ -125,7 +125,7 @@ describe('apolloProvider', () => { }) it('redirects to logout', () => { - expect(windowLocationMock).toBeCalledWith('http://localhost/vue/login') + expect(windowLocationMock).toBeCalledWith('http://localhost/login') }) })