[SalesForce] Custom Logout not working in Napili Community

I have configured a Custom Menu on the header component on my Community(Napili template) using lightning:buttonMenu and had Logout as one of the menu items. Clicking on it, it would then redirect to a page(I call it as Logout screen).

if(selectedMenuItemValue == 'Logout'){
       var urlEvent = $A.get("e.force:navigateToURL");
         urlEvent.setParams({
             "url": '/logout' 
         });
         urlEvent.fire(); 

But how can I actually implement a Logout that happens from Standard Logout item from Community's default Profile Header?

Best Answer

I would use window.location.href=salesforceurl/secure/logout.jsp

This will use the current window to navigate to logout url

Related Topic