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

fix: hide splash screens from API users (#852)

* refactor: add missing user isAPI field

* fix: hide splash screens from API users

Co-authored-by: Ivar Conradi Østhus <ivarconr@gmail.com>
This commit is contained in:
olav 2022-04-05 20:34:23 +02:00 committed by GitHub
parent b453cd5c7e
commit 6efa9fe75c
3 changed files with 15 additions and 1 deletions

View File

@ -14,6 +14,7 @@ const loadingData: IUser[] = [
createdAt: '2021-04-21T12:09:55.923Z',
rootRole: 1,
inviteLink: '',
isAPI: false,
},
{
id: 16,
@ -27,6 +28,7 @@ const loadingData: IUser[] = [
createdAt: '2021-04-21T15:54:02.765Z',
rootRole: 2,
inviteLink: '',
isAPI: false,
},
{
id: 3,
@ -40,6 +42,7 @@ const loadingData: IUser[] = [
createdAt: '2021-04-21T12:33:17.712Z',
rootRole: 1,
inviteLink: '',
isAPI: false,
},
{
id: 4,
@ -53,6 +56,7 @@ const loadingData: IUser[] = [
createdAt: '2021-04-21T15:54:02.765Z',
rootRole: 2,
inviteLink: '',
isAPI: false,
},
{
id: 5,
@ -66,6 +70,7 @@ const loadingData: IUser[] = [
createdAt: '2021-04-21T12:33:17.712Z',
rootRole: 1,
inviteLink: '',
isAPI: false,
},
];

View File

@ -5,13 +5,15 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
import { IFlags } from 'interfaces/uiConfig';
import { IAuthSplash } from 'hooks/api/getters/useAuth/useAuthEndpoint';
import { activeSplashIds, SplashId } from 'component/splash/splash';
import { useAuthUser } from 'hooks/api/getters/useAuth/useAuthUser';
export const SplashPageRedirect = () => {
const { pathname } = useLocation();
const { user } = useAuthUser();
const { splash } = useAuthSplash();
const { uiConfig, loading } = useUiConfig();
if (!splash || !uiConfig || loading) {
if (!user || !splash || !uiConfig || loading) {
// Wait for everything to load.
return null;
}
@ -21,6 +23,12 @@ export const SplashPageRedirect = () => {
return null;
}
// Read-only API users should never see splash screens
// since they don't have access to mark them as seen.
if (user.isAPI) {
return null;
}
// Find the splash page to show (if any).
const showSplashId = activeSplashIds.find(splashId => {
return (

View File

@ -10,6 +10,7 @@ export interface IUser {
rootRole: number;
seenAt: string | null;
username?: string;
isAPI: boolean;
}
export interface IPermission {