@mohasinac/appkit 4.4.4 → 4.4.5
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.
|
@@ -173,7 +173,31 @@ export function SessionProvider({ children, initialUser, endpoints: endpointOver
|
|
|
173
173
|
void normalizeError(error);
|
|
174
174
|
logger.debug("Session activity update failed", { error });
|
|
175
175
|
}
|
|
176
|
-
|
|
176
|
+
// Piggyback a fresh RBAC-relevant profile re-fetch on the same 5-minute
|
|
177
|
+
// tick. onAuthStateChanged only fires on login/logout/full-page-reload —
|
|
178
|
+
// never on client-side soft navigation — so a role/isTester/canTestAdmin
|
|
179
|
+
// flag flipped by an admin while the user already has the app open in a
|
|
180
|
+
// tab stays invisible to them indefinitely until they hard-reload or
|
|
181
|
+
// re-login. Root-caused 2026-08-20: a tester granted canTestAdmin
|
|
182
|
+
// couldn't see the Tester Hub because their SessionContext was still
|
|
183
|
+
// holding the flags from whenever they first loaded the app.
|
|
184
|
+
try {
|
|
185
|
+
const fresh = await fetchUserProfileFromServer();
|
|
186
|
+
if (!fresh || fresh.uid !== user.uid)
|
|
187
|
+
return;
|
|
188
|
+
const rbacFieldsChanged = fresh.role !== user.role ||
|
|
189
|
+
fresh.isTester !== user.isTester ||
|
|
190
|
+
fresh.canTestAdmin !== user.canTestAdmin ||
|
|
191
|
+
fresh.disabled !== user.disabled ||
|
|
192
|
+
fresh.storeId !== user.storeId;
|
|
193
|
+
if (rbacFieldsChanged)
|
|
194
|
+
setUser(fresh);
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
void normalizeError(error);
|
|
198
|
+
logger.debug("Periodic profile refresh failed", { error });
|
|
199
|
+
}
|
|
200
|
+
}, [user, ep.sessionActivity, fetchUserProfileFromServer]);
|
|
177
201
|
useEffect(() => {
|
|
178
202
|
updateSessionActivityRef.current = updateSessionActivity;
|
|
179
203
|
}, [updateSessionActivity]);
|