Promote authenticated BIM share viewers
This commit is contained in:
parent
f680d6bad2
commit
09492a5fdc
|
|
@ -4,7 +4,7 @@ const SDK_URL = "./lib/dc-camera-context.es.js?v=3";
|
||||||
import { createLogo } from "./src/ui/logo.js";
|
import { createLogo } from "./src/ui/logo.js";
|
||||||
import { applyToolbarVars } from "./src/ui/toolbar.js?v=3";
|
import { applyToolbarVars } from "./src/ui/toolbar.js?v=3";
|
||||||
import { createTemplatesMenu } from "./src/ui/templatesMenu.js?v=3";
|
import { createTemplatesMenu } from "./src/ui/templatesMenu.js?v=3";
|
||||||
import { createSettingsMenu } from "./src/ui/settingsMenu.js?v=14";
|
import { createSettingsMenu } from "./src/ui/settingsMenu.js?v=15";
|
||||||
import { createMeasurementModal } from "./src/ui/measurementModal.js";
|
import { createMeasurementModal } from "./src/ui/measurementModal.js";
|
||||||
import { createGlassSelect } from "./src/ui/glassSelect.js";
|
import { createGlassSelect } from "./src/ui/glassSelect.js";
|
||||||
import { createColorControl } from "./src/ui/controls/color.js";
|
import { createColorControl } from "./src/ui/controls/color.js";
|
||||||
|
|
@ -1774,6 +1774,14 @@ const initializeRuntimeMode = async () => {
|
||||||
console.warn("BIM session status unavailable", err);
|
console.warn("BIM session status unavailable", err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shareToken) {
|
||||||
|
const authenticatedShare = runtimeSessionInfo.authenticated === true ||
|
||||||
|
startupSharePayload?.authenticated === true ||
|
||||||
|
startupSharePayload?.mode === "standard" ||
|
||||||
|
startupSharePayload?.readonly === false;
|
||||||
|
viewerMode = authenticatedShare ? "standard" : "guest";
|
||||||
|
}
|
||||||
|
|
||||||
applyRuntimeMode();
|
applyRuntimeMode();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -651,6 +651,6 @@
|
||||||
<input id="fileInput" class="hidden" type="file"
|
<input id="fileInput" class="hidden" type="file"
|
||||||
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
accept=".xkt,.glb,.gltf,.bim,.las,.laz,.obj,.stl">
|
||||||
|
|
||||||
<script type="module" src="/dcViewer.js?v=55"></script>
|
<script type="module" src="/dcViewer.js?v=56"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -76,10 +76,13 @@ const isSharedViewerPath = () => (
|
||||||
typeof window !== "undefined" &&
|
typeof window !== "undefined" &&
|
||||||
/^\/share\/[^/]+\/?$/.test(window.location.pathname || "")
|
/^\/share\/[^/]+\/?$/.test(window.location.pathname || "")
|
||||||
);
|
);
|
||||||
const isReadonlySettingsContext = () => (
|
const isReadonlySettingsContext = () => {
|
||||||
isSharedViewerPath() ||
|
if (typeof document !== "undefined") {
|
||||||
(typeof document !== "undefined" && document.body?.dataset?.viewerMode === "guest")
|
const mode = document.body?.dataset?.viewerMode;
|
||||||
);
|
if (mode) return mode === "guest";
|
||||||
|
}
|
||||||
|
return isSharedViewerPath();
|
||||||
|
};
|
||||||
const projectSettings = typeof window !== "undefined" && window.__BIMDC_THEME__
|
const projectSettings = typeof window !== "undefined" && window.__BIMDC_THEME__
|
||||||
? { ...defaultSettings, ...window.__BIMDC_THEME__ }
|
? { ...defaultSettings, ...window.__BIMDC_THEME__ }
|
||||||
: { ...defaultSettings };
|
: { ...defaultSettings };
|
||||||
|
|
|
||||||
|
|
@ -1531,10 +1531,15 @@ const handleGetShare = async (req, res, token) => {
|
||||||
sendText(res, 404, "Share not found");
|
sendText(res, 404, "Share not found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
const session = getCurrentBimSession(req);
|
||||||
|
const authenticated = !!session;
|
||||||
sendJSON(res, 200, {
|
sendJSON(res, 200, {
|
||||||
ok: true,
|
ok: true,
|
||||||
mode: "guest",
|
mode: authenticated ? "standard" : "guest",
|
||||||
readonly: true,
|
readonly: !authenticated,
|
||||||
|
authenticated,
|
||||||
|
canShare: !BIM_AUTH_REQUIRED || authenticated,
|
||||||
|
user: session?.user || null,
|
||||||
viewer: {
|
viewer: {
|
||||||
src: publicUrlForUploadSrc(req, share.src),
|
src: publicUrlForUploadSrc(req, share.src),
|
||||||
settingsSrc: publicUrlForUploadSrc(req, share.settingsSrc || share.src),
|
settingsSrc: publicUrlForUploadSrc(req, share.settingsSrc || share.src),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue