1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-04 01:18:20 +02:00

Merge branch 'main' into feat/addons

This commit is contained in:
Fredrik Strand Oseberg 2022-02-01 15:44:01 +01:00 committed by GitHub
commit 6b605078df
2 changed files with 12 additions and 2 deletions

View File

@ -490,6 +490,8 @@ export const routes = [
layout: 'main', layout: 'main',
menu: {}, menu: {},
}, },
/* If you update this route path, make sure you update the path in SWRProvider.tsx */
{ {
path: '/login', path: '/login',
title: 'Log in', title: 'Log in',
@ -499,6 +501,7 @@ export const routes = [
layout: 'standalone', layout: 'standalone',
menu: {}, menu: {},
}, },
/* If you update this route path, make sure you update the path in SWRProvider.tsx */
{ {
path: '/new-user', path: '/new-user',
title: 'New user', title: 'New user',
@ -508,6 +511,7 @@ export const routes = [
layout: 'standalone', layout: 'standalone',
menu: {}, menu: {},
}, },
/* If you update this route path, make sure you update the path in SWRProvider.tsx */
{ {
path: '/reset-password', path: '/reset-password',
title: 'reset-password', title: 'reset-password',

View File

@ -22,17 +22,23 @@ const SWRProvider: React.FC<ISWRProviderProps> = ({
const handleFetchError = error => { const handleFetchError = error => {
setShowLoader(false); setShowLoader(false);
if (error.status === 401) { if (error.status === 401) {
cache.clear();
const path = location.pathname; const path = location.pathname;
// Only populate user with authDetails if 401 and // Only populate user with authDetails if 401 and
// error is not invalid token // error is not invalid token
if (error?.info?.name !== INVALID_TOKEN_ERROR) { if (error?.info?.name !== INVALID_TOKEN_ERROR) {
mutate(USER_CACHE_KEY, { ...error.info }, false); mutate(USER_CACHE_KEY, { ...error.info }, false);
} }
if (path === '/login') {
if (
path === '/login' ||
path === '/new-user' ||
path === '/reset-password'
) {
return; return;
} }
cache.clear();
history.push('/login'); history.push('/login');
return; return;
} }