From 76cf7ec99826f50b394dba6351bda9793c14eb55 Mon Sep 17 00:00:00 2001 From: Lera24 Date: Thu, 23 May 2024 16:59:02 +0300 Subject: [PATCH] hotfix: double call login api[WTEL-4395] --- src/api/auth/auth.js | 10 +------ .../__tests__/the-login-providers.spec.js | 10 ------- .../login/providers/the-login-providers.vue | 6 ---- src/store/modules/auth/__tests__/auth.spec.js | 28 ++++++------------- src/store/modules/auth/auth.js | 15 ++++------ 5 files changed, 15 insertions(+), 54 deletions(-) diff --git a/src/api/auth/auth.js b/src/api/auth/auth.js index dd167d60..646c4c69 100644 --- a/src/api/auth/auth.js +++ b/src/api/auth/auth.js @@ -95,13 +95,6 @@ const checkCurrentSession = async () => { } }; -const loadServiceProviders = async ({ domain }) => { - const baseUrl = '/login'; - const url = `${baseUrl}?domain=${domain}`; - const response = await instance.get(url); - return response; -}; - const clearToken = () => { localStorage.removeItem('access-token'); instance.defaults.headers['X-Webitel-Access'] = ''; @@ -116,7 +109,7 @@ const checkDomainExistence = async (domain) => { const baseUrl = '/login'; const url = `${baseUrl}?domain=${domain}`; try { - await instance.get(url); + return await instance.get(url); } catch (err) { throw err; } @@ -127,7 +120,6 @@ const AuthAPI = { login2fa, register, checkCurrentSession, - loadServiceProviders, checkDomainExistence, }; diff --git a/src/components/auth/login/providers/__tests__/the-login-providers.spec.js b/src/components/auth/login/providers/__tests__/the-login-providers.spec.js index 306edd51..e1591a96 100644 --- a/src/components/auth/login/providers/__tests__/the-login-providers.spec.js +++ b/src/components/auth/login/providers/__tests__/the-login-providers.spec.js @@ -29,16 +29,6 @@ describe('TheLoginProviders', () => { expect(wrapper.exists()).toBe(true); }); - it('loads service providers initially', () => { - const mock = vi.spyOn(store, 'dispatch').mockImplementationOnce(vi.fn()); - const wrapper = shallowMount(TheLoginProviders, { - global: { - plugins: [store], - }, - }); - expect(mock).toHaveBeenCalledWith('auth/LOAD_SERVICE_PROVIDERS'); - }); - it('should render service providers', () => { const loginProviders = { [ServiceProvider.ADFS]: {}, diff --git a/src/components/auth/login/providers/the-login-providers.vue b/src/components/auth/login/providers/the-login-providers.vue index ad0b6722..d4c19d43 100644 --- a/src/components/auth/login/providers/the-login-providers.vue +++ b/src/components/auth/login/providers/the-login-providers.vue @@ -50,12 +50,6 @@ const serviceProviders = computed(() => { function openProvider({ ticket }) { return store.dispatch('auth/EXECUTE_PROVIDER', { ticket }); } - -function loadAvailableProviders() { - return store.dispatch('auth/LOAD_SERVICE_PROVIDERS'); -} - -loadAvailableProviders();