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
slaneslane 

How to control behavior of Sites "Unauthorized" page

Hello all:

 

So here' s my situation. I have a custom site, with custom look and feel. It's fully authenticated, such that a user must log in in order to see any pages, as described here:

 

http://community.salesforce.com/sforce/board/message?board.id=sites&message.id=1463&query.id=176741#M1463

 

Ideally, if a user tries to access a restricted page when not logged in, they'll be redirected to my customized login page. But that's not what happens. They are instead sent to the Unauthorized page, which has standard Force.com Sites look and feel.

 

So, first I tried to reset what the site's "unauthorized" page is. But unlike the site template, active home page or inactive home page, there seems to be no way to reset what the "unauthorized" page is.

 

So instead I tried to make the Unauthorized page automatically redirect to my login page -- I created a custom controller, added it to the Unauthorized page, and set an action attribute on the page to call a controller method that would cause a redirect, by returning a PageReference to my custom login page. No dice: instead, I mysteriously get the "Under Construction" page when I do this. When I look at the HTTP traffic I don't see any redirect, all I see is a 503 Service Unavailable.

 

I suppose I could restyle the Unauthorized page to look like my custom login page. But why should I have to?

 

I'm really not sure where to start. Questions:

 

  1. What governs which page counts as the "unauthorized" page for a site? Is the page Id? The page name?
  2. How do I force the Unauthorized page to simply and always redirect to my login page?
Best Answer chosen by Admin (Salesforce Developers) 
slaneslane
Thanks Bulent and Ryan. The simplest thing to do here turns out to be just to make the Unauthorized page be my custom login page. Easy.

All Answers

BulentBulent

Steve,

 

You should be able to brand the unauthorized page. If you are seeing the force.com branded page even though you are using your own custom branded page, that means an error is happening at runtime when system is trying to display your custom page, failing, and showing the default page. 

 

On the second part, you can't use redirects on these pages in order to avoid infinite redirects between pages, that's why you are seeing this behavior (documented in the online help).

RyanGuestRyanGuest

On the site detail page, scroll down to the "Error Pages" section. That is where you customize what error pages are shown to users.

 

 

 See the screenshot below:

 

Force.com Sites Error Pages

slaneslane
Thanks Bulent and Ryan. The simplest thing to do here turns out to be just to make the Unauthorized page be my custom login page. Easy.
This was selected as the best answer