@sevenfold/setto-client 0.2.2 → 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 +24 -40
- package/dist/setto-client.js.map +1 -1
- package/package.json +1 -1
package/dist/setto-client.js
CHANGED
|
@@ -22661,23 +22661,23 @@ function adminRedirectUrl() {
|
|
|
22661
22661
|
}
|
|
22662
22662
|
function authCallbackType() {
|
|
22663
22663
|
const hash = window.location.hash.replace(/^#/, "");
|
|
22664
|
-
if (hash)
|
|
22665
|
-
|
|
22666
|
-
|
|
22667
|
-
}
|
|
22668
|
-
const queryType = new URLSearchParams(window.location.search).get("type");
|
|
22669
|
-
if (queryType === "invite" || queryType === "recovery") return queryType;
|
|
22664
|
+
if (!hash) return null;
|
|
22665
|
+
const type = new URLSearchParams(hash).get("type");
|
|
22666
|
+
if (type === "invite" || type === "recovery") return type;
|
|
22670
22667
|
return null;
|
|
22671
22668
|
}
|
|
22672
|
-
function
|
|
22673
|
-
|
|
22669
|
+
function clearAuthHashFromUrl() {
|
|
22670
|
+
const { pathname, search } = window.location;
|
|
22671
|
+
window.history.replaceState(null, "", pathname + search);
|
|
22674
22672
|
}
|
|
22675
|
-
function
|
|
22676
|
-
const
|
|
22677
|
-
|
|
22678
|
-
|
|
22679
|
-
|
|
22680
|
-
|
|
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
22681
|
}
|
|
22682
22682
|
function AuthGate({ children }) {
|
|
22683
22683
|
const { supabase, session, authLoading } = useSetto();
|
|
@@ -22688,38 +22688,22 @@ function AuthGate({ children }) {
|
|
|
22688
22688
|
const [error, setError] = useState(null);
|
|
22689
22689
|
const [info, setInfo] = useState(null);
|
|
22690
22690
|
const [busy, setBusy] = useState(false);
|
|
22691
|
-
const [activatingInvite, setActivatingInvite] = useState(false);
|
|
22692
22691
|
useEffect(() => {
|
|
22693
|
-
const
|
|
22694
|
-
|
|
22695
|
-
|
|
22696
|
-
|
|
22692
|
+
const inviteError = consumeInviteErrorFromUrl();
|
|
22693
|
+
if (inviteError) {
|
|
22694
|
+
setError(inviteError);
|
|
22695
|
+
setMode("signin");
|
|
22697
22696
|
return;
|
|
22698
22697
|
}
|
|
22699
|
-
|
|
22700
|
-
|
|
22701
|
-
|
|
22702
|
-
if (cancelled) return;
|
|
22703
|
-
clearAuthParamsFromUrl();
|
|
22704
|
-
if (verifyError) {
|
|
22705
|
-
setError(verifyError.message);
|
|
22706
|
-
setMode("signin");
|
|
22707
|
-
return;
|
|
22708
|
-
}
|
|
22709
|
-
setMode("set_password");
|
|
22710
|
-
}).finally(() => {
|
|
22711
|
-
if (!cancelled) setActivatingInvite(false);
|
|
22712
|
-
});
|
|
22713
|
-
return () => {
|
|
22714
|
-
cancelled = true;
|
|
22715
|
-
};
|
|
22716
|
-
}, [supabase]);
|
|
22698
|
+
const callback = authCallbackType();
|
|
22699
|
+
if (callback) setMode("set_password");
|
|
22700
|
+
}, []);
|
|
22717
22701
|
if (authLoading) {
|
|
22718
22702
|
return /* @__PURE__ */ jsx("div", { style: loadingStyle, children: "Laster …" });
|
|
22719
22703
|
}
|
|
22720
22704
|
if (session && mode !== "set_password") return /* @__PURE__ */ jsx(Fragment, { children });
|
|
22721
|
-
if (mode === "set_password" && !session
|
|
22722
|
-
return /* @__PURE__ */ jsx("div", { style: loadingStyle, children:
|
|
22705
|
+
if (mode === "set_password" && !session) {
|
|
22706
|
+
return /* @__PURE__ */ jsx("div", { style: loadingStyle, children: authCallbackType() ? "Aktiverer invitasjon …" : "Åpne lenken fra e-posten for å sette passord." });
|
|
22723
22707
|
}
|
|
22724
22708
|
const submitSignIn = async (e) => {
|
|
22725
22709
|
e.preventDefault();
|
|
@@ -22774,7 +22758,7 @@ function AuthGate({ children }) {
|
|
|
22774
22758
|
try {
|
|
22775
22759
|
const { error: updateError } = await supabase.auth.updateUser({ password });
|
|
22776
22760
|
if (updateError) throw updateError;
|
|
22777
|
-
|
|
22761
|
+
clearAuthHashFromUrl();
|
|
22778
22762
|
const { data: sessionData } = await supabase.auth.getSession();
|
|
22779
22763
|
if (sessionData.session) {
|
|
22780
22764
|
window.location.replace(editModeUrl());
|