@sevenfold/setto-client 0.2.1 → 0.2.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/dist/setto-client.js +15 -0
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
package/dist/setto-client.js
CHANGED
|
@@ -22670,6 +22670,15 @@ function clearAuthHashFromUrl() {
|
|
|
22670
22670
|
const { pathname, search } = window.location;
|
|
22671
22671
|
window.history.replaceState(null, "", pathname + search);
|
|
22672
22672
|
}
|
|
22673
|
+
function consumeInviteErrorFromUrl() {
|
|
22674
|
+
const params = new URLSearchParams(window.location.search);
|
|
22675
|
+
const code = params.get("setto_invite_error");
|
|
22676
|
+
if (!code) return null;
|
|
22677
|
+
params.delete("setto_invite_error");
|
|
22678
|
+
const qs = params.toString();
|
|
22679
|
+
window.history.replaceState(null, "", `${window.location.pathname}${qs ? `?${qs}` : ""}`);
|
|
22680
|
+
return code === "invalid" ? "Invitasjonslenken er ugyldig eller utløpt. Be administratoren om en ny." : "Kunne ikke aktivere invitasjonen.";
|
|
22681
|
+
}
|
|
22673
22682
|
function AuthGate({ children }) {
|
|
22674
22683
|
const { supabase, session, authLoading } = useSetto();
|
|
22675
22684
|
const [mode, setMode] = useState("signin");
|
|
@@ -22680,6 +22689,12 @@ function AuthGate({ children }) {
|
|
|
22680
22689
|
const [info, setInfo] = useState(null);
|
|
22681
22690
|
const [busy, setBusy] = useState(false);
|
|
22682
22691
|
useEffect(() => {
|
|
22692
|
+
const inviteError = consumeInviteErrorFromUrl();
|
|
22693
|
+
if (inviteError) {
|
|
22694
|
+
setError(inviteError);
|
|
22695
|
+
setMode("signin");
|
|
22696
|
+
return;
|
|
22697
|
+
}
|
|
22683
22698
|
const callback = authCallbackType();
|
|
22684
22699
|
if (callback) setMode("set_password");
|
|
22685
22700
|
}, []);
|