mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #1285 from gradido/fix-token-logout-redirect-to-wallet-login
Fix redirect to /logout, now redirects to the wallet login.
This commit is contained in:
commit
df982842b4
@ -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')
|
||||
|
||||
@ -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,11 @@ 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 = {
|
||||
assign: windowLocationMock,
|
||||
}
|
||||
|
||||
// mock context
|
||||
const setContextMock = jest.fn()
|
||||
const getContextMock = jest.fn(() => {
|
||||
@ -128,21 +124,8 @@ describe('apolloProvider', () => {
|
||||
expect(storeDispatchMock).toBeCalledWith('logout', null)
|
||||
})
|
||||
|
||||
describe('current route is not logout', () => {
|
||||
it('redirects to logout', () => {
|
||||
expect(routerPushMock).toBeCalledWith('/logout')
|
||||
})
|
||||
})
|
||||
|
||||
describe('current route is logout', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks()
|
||||
router.currentRoute.path = '/logout'
|
||||
})
|
||||
|
||||
it('does not redirect to logout', () => {
|
||||
expect(routerPushMock).not.toBeCalled()
|
||||
})
|
||||
it('redirects to logout', () => {
|
||||
expect(windowLocationMock).toBeCalledWith('http://localhost/login')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user