CUSTOM LOGOUT BUTTON ON LIGHTNING COMPONENT IN COMMUNITY
If you want to create your own logout button for a Community Lightning Component, you can use the window.location.replace() javascript function.
The button component (note: this example is the button only, you would typically include this in aNotification):
<aura:component implements="forceCommunity:availableForAllPageTypes" access="global"> <ui:button label="Logout" press="{!c.logout}"/> </aura:component>
And in your controller, you can redirect the user to the logout page:
({ logout : function(component, event, helper) { window.location.replace("https://YourCommunityDomain/servlet/networks/switch?startURL=%2Fsecur%2Flogout.jsp"); } })
Just replace “YourCommunityDomain” with whatever the base URL is for your community. Typically something like “MyDomain.na10.force.com”. This will redirect the user to the standard logout page for your community.
Window isn't an option when lockerservice is turned on. Does this still work?
ReplyDelete