Fix authenticated BIM share promotion
This commit is contained in:
@@ -3220,11 +3220,17 @@ header {
|
||||
}
|
||||
|
||||
body[data-viewer-mode="guest"] .tb-btn:not([data-action="measure"]):not([data-action="section"]):not([data-action="projection"]),
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) .tb-btn:not([data-action="measure"]):not([data-action="section"]):not([data-action="projection"]),
|
||||
body[data-viewer-mode="guest"] #settingsPanel,
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) #settingsPanel,
|
||||
body[data-viewer-mode="guest"] #templatesPanel,
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) #templatesPanel,
|
||||
body[data-viewer-mode="guest"] #projectNameSection,
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) #projectNameSection,
|
||||
body[data-viewer-mode="guest"] #saveProjectSection,
|
||||
body[data-viewer-mode="guest"] #modelVersionUploadButton {
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) #saveProjectSection,
|
||||
body[data-viewer-mode="guest"] #modelVersionUploadButton,
|
||||
html[data-share-startup="guest"] body:not([data-viewer-mode="standard"]) #modelVersionUploadButton {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
|
||||
+34
-5
@@ -184,6 +184,7 @@ const AUTH_SESSION_API = "/api/auth/session";
|
||||
const SHARES_API = "/api/shares";
|
||||
const COMMENTS_API = "/api/comments";
|
||||
const UPLOAD_VERSIONS_API = "/api/uploads/versions";
|
||||
const SHARE_AUTH_GUEST_PARAM = "ndc_bim_guest";
|
||||
const SHARE_PROMOTION_TIMEOUT_MS = 4500;
|
||||
|
||||
const acceptByType = {
|
||||
@@ -624,13 +625,39 @@ const getShareTokenFromPath = () => {
|
||||
const getCurrentReturnPath = () => `${window.location.pathname}${window.location.search || ""}${window.location.hash || ""}`;
|
||||
|
||||
const getShareTopLevelPromotionUrl = () => {
|
||||
const promoteUrl = startupSharePayload?.promoteUrl;
|
||||
const promoteUrl = startupSharePayload?.optionalPromoteUrl || startupSharePayload?.promoteUrl;
|
||||
return typeof promoteUrl === "string" && promoteUrl.trim() ? promoteUrl : "";
|
||||
};
|
||||
|
||||
const hasShareGuestAuthMarker = () => {
|
||||
try {
|
||||
return new URLSearchParams(window.location.search || "").get(SHARE_AUTH_GUEST_PARAM) === "1";
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const clearShareGuestAuthMarker = () => {
|
||||
if (!hasShareGuestAuthMarker()) return;
|
||||
try {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete(SHARE_AUTH_GUEST_PARAM);
|
||||
window.history.replaceState(window.history.state, "", `${url.pathname}${url.search}${url.hash}`);
|
||||
} catch (_) {
|
||||
// keep current URL if the History API is unavailable
|
||||
}
|
||||
};
|
||||
|
||||
const scheduleShareSessionPromotion = (shareToken) => {
|
||||
const silentPromoteUrl = startupSharePayload?.silentPromoteUrl;
|
||||
if (!shareToken || viewerMode !== "guest" || runtimeSessionInfo.authenticated || typeof silentPromoteUrl !== "string" || !silentPromoteUrl.trim()) {
|
||||
if (
|
||||
!shareToken ||
|
||||
hasShareGuestAuthMarker() ||
|
||||
viewerMode !== "guest" ||
|
||||
runtimeSessionInfo.authenticated ||
|
||||
typeof silentPromoteUrl !== "string" ||
|
||||
!silentPromoteUrl.trim()
|
||||
) {
|
||||
return;
|
||||
}
|
||||
let storageKey = "";
|
||||
@@ -1810,6 +1837,7 @@ const applyRuntimeMode = () => {
|
||||
|
||||
const initializeRuntimeMode = async () => {
|
||||
const shareToken = getShareTokenFromPath();
|
||||
const shareGuestAuthMarker = hasShareGuestAuthMarker();
|
||||
if (shareToken) {
|
||||
viewerMode = "guest";
|
||||
inspectorCollapsed = true;
|
||||
@@ -1849,7 +1877,8 @@ const initializeRuntimeMode = async () => {
|
||||
}
|
||||
|
||||
applyRuntimeMode();
|
||||
if (shareToken && viewerMode === "guest") {
|
||||
clearShareGuestAuthMarker();
|
||||
if (shareToken && viewerMode === "guest" && !shareGuestAuthMarker) {
|
||||
scheduleShareSessionPromotion(shareToken);
|
||||
}
|
||||
};
|
||||
@@ -5182,13 +5211,13 @@ const applyViewerState = (state) => {
|
||||
};
|
||||
|
||||
const initViewer = async () => {
|
||||
// remove preload hidden style ASAP
|
||||
await initializeRuntimeMode();
|
||||
|
||||
const preloadHidden = document.getElementById("preload-hidden");
|
||||
if (preloadHidden) {
|
||||
preloadHidden.remove();
|
||||
}
|
||||
document.body.style.opacity = "1";
|
||||
await initializeRuntimeMode();
|
||||
|
||||
const sdk = await import(SDK_URL);
|
||||
sdkRef = sdk;
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Manrope:wght@500;600;700&display=swap">
|
||||
<script src="/theme.js?v=3"></script>
|
||||
<script>
|
||||
(function () {
|
||||
if (/^\/share\/[^/]+\/?$/.test(window.location.pathname || "")) {
|
||||
document.documentElement.dataset.shareStartup = "guest";
|
||||
}
|
||||
}());
|
||||
</script>
|
||||
<script>
|
||||
// Apply persisted theme ASAP to avoid initial flash of defaults
|
||||
(function () {
|
||||
|
||||
Reference in New Issue
Block a user