mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 07:29:08 +00:00
refactor: unify localhost logic
This commit is contained in:
committed by
Carlos Valente
parent
de38f9d467
commit
161ec383fd
@@ -1,5 +1,6 @@
|
|||||||
import { PropsWithChildren, useCallback, useContext } from 'react';
|
import { PropsWithChildren, useCallback, useContext } from 'react';
|
||||||
|
|
||||||
|
import { isLocalhost } from '../../api/constants';
|
||||||
import { AppContext } from '../../context/AppContext';
|
import { AppContext } from '../../context/AppContext';
|
||||||
|
|
||||||
import PinPage from './PinPage';
|
import PinPage from './PinPage';
|
||||||
@@ -9,7 +10,6 @@ interface ProtectRouteProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function ProtectRoute({ permission, children }: PropsWithChildren<ProtectRouteProps>) {
|
export default function ProtectRoute({ permission, children }: PropsWithChildren<ProtectRouteProps>) {
|
||||||
const isLocal = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1';
|
|
||||||
const { editorAuth, operatorAuth, validate } = useContext(AppContext);
|
const { editorAuth, operatorAuth, validate } = useContext(AppContext);
|
||||||
|
|
||||||
const handleValidation = useCallback(
|
const handleValidation = useCallback(
|
||||||
@@ -29,7 +29,7 @@ export default function ProtectRoute({ permission, children }: PropsWithChildren
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isLocal || hasRelevantAuth()) {
|
if (isLocalhost || hasRelevantAuth()) {
|
||||||
// eslint-disable-next-line react/jsx-no-useless-fragment -- trying to make typescript happy
|
// eslint-disable-next-line react/jsx-no-useless-fragment -- trying to make typescript happy
|
||||||
return <>{children}</>;
|
return <>{children}</>;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user