@snapdragonsnursery/react-components 1.0.6 → 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 +3 -25
package/package.json
CHANGED
package/src/AuthButtons.jsx
CHANGED
|
@@ -180,32 +180,10 @@ function AuthButtons({ theme, setTheme, authState, setAuthState }) {
|
|
|
180
180
|
trackAuthEvent("logout", true);
|
|
181
181
|
clearUserContext();
|
|
182
182
|
|
|
183
|
-
//
|
|
184
|
-
instance.
|
|
185
|
-
|
|
186
|
-
// Clear any stored tokens from localStorage/sessionStorage
|
|
187
|
-
const msalKeys = Object.keys(localStorage).filter((key) =>
|
|
188
|
-
key.startsWith("msal.")
|
|
189
|
-
);
|
|
190
|
-
msalKeys.forEach((key) => localStorage.removeItem(key));
|
|
191
|
-
|
|
192
|
-
const msalSessionKeys = Object.keys(sessionStorage).filter((key) =>
|
|
193
|
-
key.startsWith("msal.")
|
|
194
|
-
);
|
|
195
|
-
msalSessionKeys.forEach((key) => sessionStorage.removeItem(key));
|
|
196
|
-
|
|
197
|
-
// Force a re-render by updating the auth state
|
|
198
|
-
setAuthState({
|
|
199
|
-
isAuthenticated: false,
|
|
200
|
-
accountsCount: 0,
|
|
201
|
-
account: null,
|
|
202
|
-
instance: null,
|
|
183
|
+
// Use MSAL's built-in logout with redirect
|
|
184
|
+
await instance.logoutRedirect({
|
|
185
|
+
postLogoutRedirectUri: "/", // or your desired landing page
|
|
203
186
|
});
|
|
204
|
-
|
|
205
|
-
// Clear profile picture
|
|
206
|
-
setProfilePicture(null);
|
|
207
|
-
|
|
208
|
-
console.log("Local logout completed - user remains on site");
|
|
209
187
|
} catch (error) {
|
|
210
188
|
console.error("Logout failed:", error);
|
|
211
189
|
trackError(error, { context: "logout" });
|