2

Below is what I have implemented:

 <aura:if isTrue="{!v.user != NULL}">
    <ui:outputText value="{!v.user.Name}"/> 
    <aura:set attribute="else">
    <ui:outputText value="Guest"/>
    </aura:set>
</aura:if>

I am trying to display text Guest if I am accessing the Community URL without any login user (say using Chrome's Incognito window). What I am getting to display is: Customer Portal Site Guest User

4

I'm fairly certain that NULL is case sensitive.

Try this:

<aura:if isTrue="{!v.user != null}">

And it looks like the user is never null. If the user has not logged in, then they are a Customer Portal Site Guest User. If they have, they will get some other name. You should probably make your test something like:

<aura:if isTrue="{!and(v.user != null, v.user.Name != 'Customer Portal Site Guest User')}">
| improve this answer | |
  • It seemed working, BUT just for half a second and refreshing to Customer Portal Site Guest User again. Am I am still missing something to include? – Arnold Jr. May 14 '17 at 0:39
  • I'm guessing that before you query completed, the user WAS null. Then, it had a value. Your user really is the Customer Portal Site Guest User. Your logic is ok, now you need to figure out why you are getting the guest user. Look at your controller, try debugging your Apex and JS code. – Caspar Harmer May 14 '17 at 0:56
  • My JScontroller contains basic doInit function and Apex controller has a query to fetch the logged in user by Id == UserInfo.getUserId(). I am clueless at this point. Could you please tell me the ways I can debug? – Arnold Jr. May 14 '17 at 1:37
  • 2
    Updated my answer - see if this works – Caspar Harmer May 14 '17 at 4:00
  • 2
    @ArnoldJr. UserInfo.getUserId() never returns null. There is a "guest user" account created for each community, so you'll need to check to see if the logged in user is a guest user. This is true for all communities, portals, and so on. – sfdcfox May 14 '17 at 4:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.