function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jon Mountjoy_Jon Mountjoy_ 

How to force authentication before viewing a page?

Hi

 

I have a site (called "protected") with portal setup.  Login on the portal works.

 

I have a page ("foo") on that site. The page just has the words "hello". 

 

How do I prevent:

 

/protected/foo from being accessible if I'm not logged in?  Right now it is. Have I made a mistake? Ideally I'd like all anonymous users to be kicked back to the login prompt.

 

Thanks,
Jon

 

Best Answer chosen by Admin (Salesforce Developers) 
BulentBulent

Do not enable the "foo" page for your public site but enable it for the portal profiles

When an unauthenticated visitors tries to access the page they will get authorization required page. 

All Answers

BulentBulent

Do not enable the "foo" page for your public site but enable it for the portal profiles

When an unauthenticated visitors tries to access the page they will get authorization required page. 

This was selected as the best answer
Jon Mountjoy_Jon Mountjoy_

Ah.  I missed the "Enabled Visualforce Page Access" in the profiles.   So to ensure that hitting page Foo results in an authentication, I simply have to

 a) Remove it from the Guest User security profile for that site

 b) Add it to the Authenticated Portal User security profile

 

If that's how it works, what's the purpose of the Site Visualforce Pages list for the Site?  (Because won't all pages be in either the Guest or Authenticated profiles?)

 

Thanks,
Jon 

BulentBulent

Site Visualforce Pages Related list and  Public Access Settings Visualforce ages are the same realted list. We have it on the site details for better usability.

 

when you create a visualforce page it is not automatically enabled for profiles. That's why you need to enable for our site or for portal users or for internal users.

 

If the page is a valid page and it's not enabled for our site, when a visitor tries to access the page site displays authentication required page, after authentication user may or may no access the page depending on the authenticated suer profile

 

If the page doesn't exists then site shows page not found page.