@volr/react 0.1.75 → 0.1.76
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/index.cjs +6 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -18730,7 +18730,7 @@ function useVolrAuthCallback(options = {}) {
|
|
|
18730
18730
|
const { clearUrlParams = true } = options;
|
|
18731
18731
|
const { setUser } = useVolrContext();
|
|
18732
18732
|
const { setAccessToken, setRefreshToken, client } = useInternalAuth();
|
|
18733
|
-
const [isLoading, setIsLoading] = react.useState(
|
|
18733
|
+
const [isLoading, setIsLoading] = react.useState(false);
|
|
18734
18734
|
const [error, setError] = react.useState(null);
|
|
18735
18735
|
const [isNewUser, setIsNewUser] = react.useState(false);
|
|
18736
18736
|
const [user, setLocalUser] = react.useState(null);
|
|
@@ -18754,12 +18754,16 @@ function useVolrAuthCallback(options = {}) {
|
|
|
18754
18754
|
const handleCallback = async () => {
|
|
18755
18755
|
if (typeof window === "undefined") return;
|
|
18756
18756
|
if (hasProcessed.current) return;
|
|
18757
|
-
hasProcessed.current = true;
|
|
18758
18757
|
const searchParams = new URLSearchParams(window.location.search);
|
|
18759
18758
|
const authCode = searchParams.get("code");
|
|
18760
18759
|
const errorParam = searchParams.get("error");
|
|
18761
18760
|
const isNew = searchParams.get("isNewUser") === "true";
|
|
18762
18761
|
const warning = searchParams.get("warning");
|
|
18762
|
+
if (!authCode && !errorParam) {
|
|
18763
|
+
return;
|
|
18764
|
+
}
|
|
18765
|
+
hasProcessed.current = true;
|
|
18766
|
+
setIsLoading(true);
|
|
18763
18767
|
if (warning) {
|
|
18764
18768
|
console.warn(`[Volr] ${warning}`);
|
|
18765
18769
|
}
|
|
@@ -18770,13 +18774,6 @@ function useVolrAuthCallback(options = {}) {
|
|
|
18770
18774
|
options.onError?.(errorMsg);
|
|
18771
18775
|
return;
|
|
18772
18776
|
}
|
|
18773
|
-
if (!authCode) {
|
|
18774
|
-
const errorMsg = "No authorization code found. Please try logging in again.";
|
|
18775
|
-
setError(errorMsg);
|
|
18776
|
-
setIsLoading(false);
|
|
18777
|
-
options.onError?.(errorMsg);
|
|
18778
|
-
return;
|
|
18779
|
-
}
|
|
18780
18777
|
if (!authCode.startsWith("volr_auth_")) {
|
|
18781
18778
|
const errorMsg = "Invalid authorization code format";
|
|
18782
18779
|
setError(errorMsg);
|