@snapdragonsnursery/react-components 1.0.5 → 1.0.7
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/package.json +1 -1
- package/src/AuthButtons.jsx +5 -29
package/package.json
CHANGED
package/src/AuthButtons.jsx
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
clearUserContext,
|
|
25
25
|
} from "./telemetry";
|
|
26
26
|
import ThemeToggle from "./ThemeToggle";
|
|
27
|
-
import { Menu } from "@headlessui/react";
|
|
28
27
|
import { createPopper } from "@popperjs/core";
|
|
29
28
|
|
|
30
29
|
const isMobile = window.innerWidth < 640;
|
|
@@ -181,32 +180,10 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
|
|
|
181
180
|
trackAuthEvent("logout", true);
|
|
182
181
|
clearUserContext();
|
|
183
182
|
|
|
184
|
-
//
|
|
185
|
-
instance.
|
|
186
|
-
|
|
187
|
-
// Clear any stored tokens from localStorage/sessionStorage
|
|
188
|
-
const msalKeys = Object.keys(localStorage).filter((key) =>
|
|
189
|
-
key.startsWith("msal.")
|
|
190
|
-
);
|
|
191
|
-
msalKeys.forEach((key) => localStorage.removeItem(key));
|
|
192
|
-
|
|
193
|
-
const msalSessionKeys = Object.keys(sessionStorage).filter((key) =>
|
|
194
|
-
key.startsWith("msal.")
|
|
195
|
-
);
|
|
196
|
-
msalSessionKeys.forEach((key) => sessionStorage.removeItem(key));
|
|
197
|
-
|
|
198
|
-
// Force a re-render by updating the auth state
|
|
199
|
-
setAuthState({
|
|
200
|
-
isAuthenticated: false,
|
|
201
|
-
accountsCount: 0,
|
|
202
|
-
account: null,
|
|
203
|
-
instance: null,
|
|
183
|
+
// Use MSAL's built-in logout with redirect
|
|
184
|
+
await instance.logoutRedirect({
|
|
185
|
+
postLogoutRedirectUri: "/", // or your desired landing page
|
|
204
186
|
});
|
|
205
|
-
|
|
206
|
-
// Clear profile picture
|
|
207
|
-
setProfilePicture(null);
|
|
208
|
-
|
|
209
|
-
console.log("Local logout completed - user remains on site");
|
|
210
187
|
} catch (error) {
|
|
211
188
|
console.error("Logout failed:", error);
|
|
212
189
|
trackError(error, { context: "logout" });
|
|
@@ -308,8 +285,7 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
|
|
|
308
285
|
return (
|
|
309
286
|
<div className="relative inline-block text-left">
|
|
310
287
|
<div>
|
|
311
|
-
<
|
|
312
|
-
as="div"
|
|
288
|
+
<button
|
|
313
289
|
ref={buttonRef}
|
|
314
290
|
className="focus:outline-none"
|
|
315
291
|
onClick={() => setMenuOpen((open) => !open)}
|
|
@@ -332,7 +308,7 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
|
|
|
332
308
|
</span>
|
|
333
309
|
</div>
|
|
334
310
|
)}
|
|
335
|
-
</
|
|
311
|
+
</button>
|
|
336
312
|
</div>
|
|
337
313
|
{menuOpen && (
|
|
338
314
|
<div
|