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

Fix/login redirect set password (#652)

* fix: don't redirect when path is reset-password or new-user

* fix: add comments to relevant routes

* fix: update swr provider
This commit is contained in:
Fredrik Strand Oseberg 2022-02-01 14:47:14 +01:00 committed by GitHub
parent f4f8b15736
commit 5c14929f7b
2 changed files with 12 additions and 2 deletions

View File

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

View File

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