From 2ade845aa77d8f110fcb0b36f5d8d9e682848bd7 Mon Sep 17 00:00:00 2001 From: Zoia R Date: Tue, 6 Sep 2022 18:42:31 +0300 Subject: [PATCH] =?UTF-8?q?feat:=20=F0=9F=8E=B8=20ott-2739-block-checkDevi?= =?UTF-8?q?ce?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/features/AuthStore/helpers.tsx | 6 ++++++ src/features/AuthStore/hooks/useAuth.tsx | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index b0f5102b..60e9908c 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -1,6 +1,8 @@ import type { UserManagerSettings } from 'oidc-client' import { WebStorageStateStore } from 'oidc-client' +import includes from 'lodash/includes' + import { client } from 'config/clients' import { AUTH_SERVICE } from 'config/routes' import { ClientIds, ClientNames } from 'config/clients/types' @@ -56,3 +58,7 @@ export const getClientSettings = (): Settings => ({ silent_redirect_uri: `${window.location.origin ?? window.origin}/silent-refresh.html`, userStore: new WebStorageStateStore({ store: window.localStorage }), }) + +const disableCheckNewDeviceClients = ['lff', 'facr'] + +export const noCheckNewDevise = includes(disableCheckNewDeviceClients, client.name) diff --git a/src/features/AuthStore/hooks/useAuth.tsx b/src/features/AuthStore/hooks/useAuth.tsx index 83248447..45e8a76e 100644 --- a/src/features/AuthStore/hooks/useAuth.tsx +++ b/src/features/AuthStore/hooks/useAuth.tsx @@ -13,7 +13,6 @@ import isString from 'lodash/isString' import isBoolean from 'lodash/isBoolean' import { PAGES } from 'config' -import { client } from 'config/clients' import { addLanguageUrlParam, @@ -30,7 +29,7 @@ import { queryParamStorage } from 'features/QueryParamsStorage' import { getUserInfo } from 'requests/getUserInfo' import { checkDevice, FailedResponse } from 'requests/checkDevice' -import { getClientSettings } from '../helpers' +import { getClientSettings, noCheckNewDevise } from '../helpers' export const useAuth = () => { const { changeLang, lang } = useLexicsStore() @@ -168,11 +167,14 @@ export const useAuth = () => { }, [reChekNewDevice, userManager]) useEffect(() => { - if (client.name !== 'instat') return undefined + if (noCheckNewDevise) return undefined const startCheckDevice = setInterval(checkNewDevice, 20000) isNewDeviceLogin && clearInterval(startCheckDevice) return () => clearInterval(startCheckDevice) - }, [checkNewDevice, isNewDeviceLogin, setIsNewDeviceLogin]) + }, [checkNewDevice, + isNewDeviceLogin, + setIsNewDeviceLogin, + ]) useEffect(() => { // попытаемся обновить токен используя refresh_token