7

I'm working on a customized portal login using sites and for one of the pages we would like to have a different display based on whether the user has already been authenticated or not.

Looking through the Visualforce Docs for the $Site global variable I can see $Site.isPasswordExpired and $Site.LoginEnabled, but can't find anything to tell if the user is authenticated. Are there any options for this?

2 Answers 2

14

Use the profile Id .

If you want logic in controller use the Userinfo class and if you want on page {!$Profile.Id} {!$Profile.Name}.Clearly if its not logged in user then profile will be guest user .Thats the clue.Also in your case best use of dynamic apex component of Visualforce can be used .Refer the docs below also you may google about dynamic apex component in vf

http://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_components_intro.htm

Closer logic :{!NOT(ISPICKVAL($User.UserType,'Guest'))}

3
  • Thanks Mohith, looked into this deeper and I think this would be a little closer {!$NOT(ISPICKVAL($User.UserType,'Guest'))} (return true if user is authenticated, false if not) , could you update your answer for anyone who looks at this later? Commented Oct 5, 2012 at 19:35
  • I have updated .I have highlighted what to look for basically in this case its user of type Guest or profile is of Guest User Type Commented Oct 5, 2012 at 19:47
  • lol, nice update, would have been better if I didn't include a typo in my suggestion ... {!NOT(ISPICKVAL($User.UserType,'Guest'))} is the correct way (drop the leading $) Commented Oct 8, 2012 at 20:09
0

I'm guessing look for the sessionId - {!$Api.Session_ID} ? Check for the presence of a Session Id. My assumption is the presence of a Session Id is representative of an authenticated user session.

1
  • Can you edit your answer a bit?
    – Saariko
    Commented Oct 9, 2012 at 10:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .