Find your content:

Search form

You are here

How to tell if a user is authenticated in a sites visualforce page

 
Share

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?


Attribution to: Ralph Callaway

Possible Suggestion/Solution #1

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.


Attribution to: techtrekker

Possible Suggestion/Solution #2

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


Attribution to: Mohith Shrivastava
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/1987

My Block Status

My Block Content