Logout Button from MSAL in TopNavigation #721
-
Thanks so much for giving us cloudscape! I've been enjoying using it while building out an application for work. I'm using @azure/msal-react to allow login and logout of internal employees using their microsoft 365 credentials. I'd love to allow these users to logout by simply clicking the logout button provided by the msal-react library (inside a TopNavigation dropdown menu). Here's what the logout component looks like: export const AdminSignOutButton = () => {
const { instance } = useMsal();
const handleLogout = (logoutType) => {
if (logoutType === "popup") {
instance.logoutPopup({
postLogoutRedirectUri: "/",
mainWindowRedirectUri: "/" // redirects the top level app after logout
});
}
}
return (
<Button variant="secondary" className="ml-auto" onClick={() => handleLogout("popup")}>Sign out</Button>
);
} Any help integrating this component into TopNavigation would be extremely appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hello Jeffrey, thank you for reaching out. Our Top Navigation component doesn't support a custom component to be used in the menu-dropdown. Alternatively, I'd recommend you to use our supported Here's how it could look like: {
type: 'button',
variant: 'primary-button',
text: 'Log out',
onClick: () => handleLogout("popup"),
}, Let me know if there's any other question you have. Thank you! |
Beta Was this translation helpful? Give feedback.
Hello Jeffrey, thank you for reaching out.
Our Top Navigation component doesn't support a custom component to be used in the menu-dropdown.
Alternatively, I'd recommend you to use our supported
button
inside the menu-dropdown. It has aonClick
property that specifies the event handler called when the utility is clicked. You could then use this to trigger your customhandleLogout
logic.Here's how it could look like:
Let me know if there's any other question you have.
Thank you!