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?

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'))}

  • 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? – Ralph Callaway Oct 5 '12 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 – Mohith Shrivastava Oct 5 '12 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 $) – Ralph Callaway Oct 8 '12 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.

  • Can you edit your answer a bit? – Saariko Oct 9 '12 at 10:57

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.