UBERF-9537: Fix Invalid navigate to guest not authorised (#8121)

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev
2025-03-03 12:53:40 +07:00
committed by Andrey Sobolev
parent c5c0ab9808
commit a6b8d6cd09
13 changed files with 140 additions and 61 deletions
@@ -28,6 +28,7 @@
closePopup,
fetchMetadataLocalStorage,
getCurrentLocation,
isSameSegments,
locationStorageKeyId,
locationToUrl,
navigate,
@@ -58,11 +59,19 @@
e.preventDefault()
closePopup()
closePopup()
if (wsUrl !== getCurrentLocation().path[1]) {
const last = localStorage.getItem(`${locationStorageKeyId}_${wsUrl}`)
if (last !== null) {
navigate(JSON.parse(last))
} else navigate({ path: [workbenchId, wsUrl] })
const current = getCurrentLocation()
if (wsUrl !== current.path[1]) {
let last: Location | undefined
try {
last = JSON.parse(localStorage.getItem(`${locationStorageKeyId}_${wsUrl}`) ?? '')
} catch (err: any) {
// Ignore
}
if (last != null && isSameSegments(last, current, 2)) {
navigate(last)
} else {
navigate({ path: [workbenchId, wsUrl] })
}
}
}
}
@@ -148,7 +157,7 @@
{/if}
</div>
<div class="p-2 ml-2 mb-4 select-text flex-col bordered">
{decodeTokenPayload(getMetadata(presentation.metadata.Token) ?? '').workspace}
{decodeTokenPayload(getMetadata(presentation.metadata.Token) ?? '').workspace ?? ''}
</div>
{/if}
<div class="ap-scroll">
@@ -78,7 +78,8 @@
showPopup,
TooltipInstance,
workbenchSeparators,
resizeObserver
resizeObserver,
isSameSegments
} from '@hcengineering/ui'
import view from '@hcengineering/view'
import {
@@ -429,9 +430,12 @@
const last = localStorage.getItem(`${locationStorageKeyId}_${loc.path[1]}`)
if (last != null) {
const lastValue = JSON.parse(last)
navigateDone = navigate(lastValue)
if (navigateDone) {
return
if (isSameSegments(lastValue, loc, 2)) {
navigateDone = navigate(lastValue)
if (navigateDone) {
return
}
}
}
if (app === undefined && !navigateDone) {