Created by
jprichter
2016-09-19
public class NapiliCommunityController {
@AuraEnabled
public static User getLoggedInUser(){
return [SELECT Id, Contact.AccountId FROM User WHERE Id =: UserInfo.getUserId() LIMIT 1];
}
}
<aura:component controller= "NapiliCommunityController" implements= "forceCommunity:availableForAllPageTypes" access= "global" >
<aura:handler name= "init" value= "{!this}" action= "{!c.redirectToAccount}" />
</aura:component>
({
redirectToAccount : function ( component , event , helper ) {
var loggedInUser ;
var state ;
var navEvt ;
var action = component . get ( "c.getLoggedInUser" );
action . setCallback ( this , function ( response ) {
state = response . getState ();
if ( state === "SUCCESS" ) {
loggedInUser = response . getReturnValue ();
navEvt = $A . get ( "e.force:navigateToSObject" );
navEvt . setParams ({
"recordId" : loggedInUser . Contact . AccountId ,
"slideDevName" : "detail"
});
navEvt . fire ();
}
});
$A . enqueueAction ( action );
}
})