• Carter Mellor
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Is there a way to recognise a logged in community user on a force.com site? By recognise, I mean if a visualforce page or apex controller were to call a {!$User.FirstName} variable or something similar.
From what I can see, it looks like the site forces the everyone into the Guest user.
I'm passing a custom class wrapper from an apex controller to a Lightning​ component, then later send it back using JSON.Stringify(theWrapper). But the apex controller can't deserialize the wrapper, giving me the error above. I've narrowed it down to lookup fields somehow getting converted from a string of the id to a whole object while in the lightning component.
Basically, theObject.Lookup__c = '0000000000123'. From the apex controller, it can be read as {"theObject":{"Lookup__c":"0000000000123"}}.
But when passed back from the lightning component, it's read as {"theObject":{"Lookup__c":{"id":"0000000000123", "name":"Lookup record"}}}
I think it's unable to deserialize because it's no longer just a string.

For reference, I'm trying to deserialise like this:
@AuraEnabled
public static String upsertSelectedBooking (String sbwString){
        
    system.debug('sbwString: ' + sbwString);
        
    selectedBookingWrapper sbw = (selectedBookingWrapper)System.JSON.deserialize(sbwString, selectedBookingWrapper.class);

    //The rest
    //...
}

How should I go about handling this?
Is there a way to recognise a logged in community user on a force.com site? By recognise, I mean if a visualforce page or apex controller were to call a {!$User.FirstName} variable or something similar.
From what I can see, it looks like the site forces the everyone into the Guest user.