dauth-context-react 6.6.1 → 6.6.2
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.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +21 -0
package/dist/index.js
CHANGED
|
@@ -2211,6 +2211,18 @@ var DauthProvider = (props) => {
|
|
|
2211
2211
|
autoLoginAction(ctx);
|
|
2212
2212
|
}
|
|
2213
2213
|
}, []);
|
|
2214
|
+
(0, import_react2.useEffect)(() => {
|
|
2215
|
+
const handleVisibilityChange = () => {
|
|
2216
|
+
if (document.visibilityState === "visible" && !dauthState.isAuthenticated && !dauthState.isLoading) {
|
|
2217
|
+
autoLoginAction(ctx);
|
|
2218
|
+
}
|
|
2219
|
+
};
|
|
2220
|
+
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
2221
|
+
return () => document.removeEventListener(
|
|
2222
|
+
"visibilitychange",
|
|
2223
|
+
handleVisibilityChange
|
|
2224
|
+
);
|
|
2225
|
+
}, [ctx, dauthState.isAuthenticated, dauthState.isLoading]);
|
|
2214
2226
|
const loginWithRedirect = (0, import_react2.useCallback)(() => {
|
|
2215
2227
|
const base = `${getClientBasePath()}/${domainName}/${routes.signin}`;
|
|
2216
2228
|
const url = env ? `${base}?env=${encodeURIComponent(env)}` : base;
|