@coreiam/auth 1.0.7 → 1.0.8
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/nextjs/provider.js +13 -4
- package/package.json +1 -1
package/dist/nextjs/provider.js
CHANGED
|
@@ -16,9 +16,9 @@ const AuthContext = (0, react_1.createContext)({
|
|
|
16
16
|
register: async () => ({ error: 'CoreIAMProvider is not mounted' }),
|
|
17
17
|
refetchIdentity: async () => { },
|
|
18
18
|
});
|
|
19
|
-
function CoreIAMProvider({ children, initialIdentity
|
|
20
|
-
const [identity, setIdentity] = (0, react_1.useState)(initialIdentity);
|
|
21
|
-
const [isLoading, setIsLoading] = (0, react_1.useState)(initialIdentity ===
|
|
19
|
+
function CoreIAMProvider({ children, initialIdentity, redirects = {}, }) {
|
|
20
|
+
const [identity, setIdentity] = (0, react_1.useState)(initialIdentity ?? null);
|
|
21
|
+
const [isLoading, setIsLoading] = (0, react_1.useState)(initialIdentity === undefined);
|
|
22
22
|
const router = (0, navigation_1.useRouter)();
|
|
23
23
|
const refetchIdentity = async () => {
|
|
24
24
|
try {
|
|
@@ -33,7 +33,16 @@ function CoreIAMProvider({ children, initialIdentity = null, redirects = {}, })
|
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
35
|
(0, react_1.useEffect)(() => {
|
|
36
|
-
|
|
36
|
+
// FIX: was `initialIdentity === null`, which can't tell "SSR ran and
|
|
37
|
+
// confirmed you're logged out" (a correct, final null) apart from "no
|
|
38
|
+
// SSR value was ever provided" (a real undefined). Since layout.tsx
|
|
39
|
+
// always calls getSession() and passes its result — even when that
|
|
40
|
+
// result legitimately is null — every logged-out page view was
|
|
41
|
+
// treated as "no SSR value, fetch again," firing a second, wholly
|
|
42
|
+
// redundant /auth/profile call for something SSR had already
|
|
43
|
+
// determined. undefined (the prop genuinely omitted) is the only case
|
|
44
|
+
// that should trigger this fallback fetch.
|
|
45
|
+
if (initialIdentity === undefined) {
|
|
37
46
|
refetchIdentity();
|
|
38
47
|
}
|
|
39
48
|
else {
|