fix(ui): iframe and jwt behaviour
This commit is contained in:
parent
fd9e493038
commit
9d924b2d69
3 changed files with 17 additions and 8 deletions
|
|
@ -5,7 +5,6 @@ import { Loader } from 'UI';
|
|||
import withSiteIdUpdater from 'HOCs/withSiteIdUpdater';
|
||||
|
||||
import * as routes from './routes';
|
||||
import { GLOBAL_HAS_NO_RECORDINGS } from 'App/constants/storageKeys';
|
||||
import { Map } from 'immutable';
|
||||
import NotFoundPage from 'Shared/NotFoundPage';
|
||||
import { ModalProvider } from 'Components/Modal';
|
||||
|
|
@ -49,7 +48,7 @@ function IFrameRoutes(props: Props) {
|
|||
return (
|
||||
<ModalProvider>
|
||||
<Layout hideHeader={true}>
|
||||
<Loader loading={loading} className='flex-1'>
|
||||
<Loader loading={!!loading} className='flex-1'>
|
||||
<Suspense fallback={<Loader loading={true} className='flex-1' />}>
|
||||
<Switch key='content'>
|
||||
<Route exact strict path={withSiteId(SESSION_PATH, siteIdList)}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ const Router: React.FC<RouterProps> = (props) => {
|
|||
|
||||
const handleDestinationPath = () => {
|
||||
if (!isLoggedIn && location.pathname !== routes.login()) {
|
||||
localStorage.setItem(GLOBAL_DESTINATION_PATH, location.pathname);
|
||||
localStorage.setItem(GLOBAL_DESTINATION_PATH, location.pathname + location.search);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -80,16 +80,25 @@ const Router: React.FC<RouterProps> = (props) => {
|
|||
if (
|
||||
destinationPath &&
|
||||
destinationPath !== routes.login() &&
|
||||
destinationPath !== routes.signup() &&
|
||||
destinationPath !== '/'
|
||||
) {
|
||||
history.push(destinationPath + location.search);
|
||||
const url = new URL(destinationPath, window.location.origin);
|
||||
checkParams(url.search)
|
||||
history.push(destinationPath);
|
||||
localStorage.removeItem(GLOBAL_DESTINATION_PATH);
|
||||
}
|
||||
};
|
||||
|
||||
const checkParams = (search?: string) => {
|
||||
const _isIframe = checkParam('iframe', IFRAME, search);
|
||||
const _isJwt = checkParam('jwt', JWT_PARAM, search);
|
||||
setIsIframe(_isIframe);
|
||||
setIsJwt(_isJwt);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setIsIframe(checkParam('iframe', IFRAME));
|
||||
setIsJwt(checkParam('jwt', JWT_PARAM));
|
||||
checkParams();
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -434,6 +434,7 @@ export function deleteCookie(name: string, path: string, domain: string) {
|
|||
* @function
|
||||
* @param {string} paramName - The name of the URL parameter to check.
|
||||
* @param {string} [storageKey] - The optional key to use for storing the result in localStorage.
|
||||
* @param search
|
||||
* @returns {boolean} - Returns true if the parameter exists and its value is 'true'. Otherwise, returns false.
|
||||
*
|
||||
* @example
|
||||
|
|
@ -448,8 +449,8 @@ export function deleteCookie(name: string, path: string, domain: string) {
|
|||
* does not exist, and a storageKey is provided, any existing localStorage entry with the storageKey
|
||||
* is removed.
|
||||
*/
|
||||
export const checkParam = (paramName: string, storageKey?: string): boolean => {
|
||||
const urlParams = new URLSearchParams(window.location.search);
|
||||
export const checkParam = (paramName: string, storageKey?: string, search?: string): boolean => {
|
||||
const urlParams = new URLSearchParams(search ? search : window.location.search);
|
||||
const paramValue = urlParams.get(paramName);
|
||||
|
||||
const existsAndTrue = paramValue && paramValue === 'true' || paramValue?.length > 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue