aura.redirect not working with LWC
Well after doing some research I found out that apparently and according to René Winkelmeyer (Salesforce Principal Developer Evangelist) in this GitHub Issue:
lightning-navigation is currently not a supported experience for Communities.
In Summer '19, Salesforce enhanced the support of lightning-navigation in Community with comm__namedPage (instead of standard__namedPage), pageReferences and state.
https://releasenotes.docs.salesforce.com/en-us/summer19/release-notes/rn_lwc_modules.htm
export default class myClass extends NavigationMixin(LightningElement) {
//...
goToFAQCategoryMesInstallations() {
this[NavigationMixin.Navigate]({
type: 'comm__namedPage',
attributes: {
pageName: 'faq',
},
state: {
'category': 'Mes_installations'
}
});
}
}
this will redirect you to 'yourCommunity'/s/faq?category=Mes_installations
Found the solution (workaround) for this, you can return the url of the PageReference retrieved from Site.login(), then you'll just need to window.open(url, '_self') in the Component's js. As for the PageReference itself it is not a valid type to be returned by AuraEnabled methods.