@snokam/auth 5.3.2 → 5.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,12 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [5.3.3](https://github.com/snokam/components/compare/@snokam/auth@5.3.2...@snokam/auth@5.3.3) (2026-10-14)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- send test operators from "no access" to the Vis som picker, land on Min side ([#2953](https://github.com/snokam/components/issues/2953)) ([dcce011](https://github.com/snokam/components/commit/dcce011160cd4b0d5661c41ce372ee15b905ebf9)), closes [#2949](https://github.com/snokam/components/issues/2949)
|
|
11
|
+
|
|
6
12
|
## [5.3.2](https://github.com/snokam/components/compare/@snokam/auth@5.3.1...@snokam/auth@5.3.2) (2026-10-14)
|
|
7
13
|
|
|
8
14
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
PageContentProvider,
|
|
9
9
|
} from "@snokam/sanity-page-content/app-router/providers";
|
|
10
10
|
import { AccessHelp } from "./AccessHelp";
|
|
11
|
+
import { usePickerRedirect } from "./usePickerRedirect";
|
|
11
12
|
|
|
12
13
|
const ACCESS_GATE_PAGE_KEY = "access-gate";
|
|
13
14
|
|
|
@@ -20,8 +21,9 @@ export const NotProvisioned = ({ appKey }: Props) => {
|
|
|
20
21
|
queryKey: ["access-gate-content", appKey],
|
|
21
22
|
queryFn: () => loadAppContent(appKey),
|
|
22
23
|
});
|
|
24
|
+
const checkingPicker = usePickerRedirect();
|
|
23
25
|
|
|
24
|
-
if (isPending) {
|
|
26
|
+
if (isPending || checkingPicker) {
|
|
25
27
|
return <PageLoader />;
|
|
26
28
|
}
|
|
27
29
|
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { useOptionalConfig } from "@snokam/tenant";
|
|
5
|
+
import { impersonationPickerUrl } from "../../impersonation/required";
|
|
6
|
+
|
|
7
|
+
const PICKER_BUSINESSES_PATH = "/api/impersonation/businesses";
|
|
8
|
+
|
|
9
|
+
// The picker's businesses route answers 200 only with persona mode on and an operator's own
|
|
10
|
+
// token, so a signed-in operator who is no employee here goes to pick a test user instead.
|
|
11
|
+
export function usePickerRedirect(): boolean {
|
|
12
|
+
const platformBaseUrl = useOptionalConfig()?.NEXT_PUBLIC_PLATFORM_BASE_URL;
|
|
13
|
+
const [checking, setChecking] = useState(Boolean(platformBaseUrl));
|
|
14
|
+
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (!platformBaseUrl) return;
|
|
17
|
+
let cancelled = false;
|
|
18
|
+
const basePath = process.env.NEXT_PUBLIC_BASE_PATH ?? "";
|
|
19
|
+
|
|
20
|
+
fetch(`${basePath}${PICKER_BUSINESSES_PATH}`, { credentials: "include" })
|
|
21
|
+
.then((response) => {
|
|
22
|
+
if (cancelled) return;
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
setChecking(false);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
window.location.replace(
|
|
28
|
+
impersonationPickerUrl(platformBaseUrl, window.location.href)
|
|
29
|
+
);
|
|
30
|
+
})
|
|
31
|
+
.catch(() => {
|
|
32
|
+
if (!cancelled) setChecking(false);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
cancelled = true;
|
|
37
|
+
};
|
|
38
|
+
}, [platformBaseUrl]);
|
|
39
|
+
|
|
40
|
+
return checking;
|
|
41
|
+
}
|