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
benA360benA360 

Visualforce page suddenly requires authorisation

Hi there, I have been developing a VisualForce page for a client, accessed via their 'Sites' site. I had initially set this up and it was working fine, however today I made a change and when I tried to access the page to check the change, it told me I had to login.

 

The page was setup for public access with no auth required, and was working as such. I've checked all permissions, and they are as they were. I haven't changed the code to access any objects that I wasn't accessing before, and the read permissions are there for the objects I am accessing.

 

I'm totally stuck as to know what to do next!! Any help appreciated :)

 

Regards, Ben

Best Answer chosen by Admin (Salesforce Developers) 
benA360benA360

Problem solved - it was a bug. I had this in my page code:

 

<apex:outputText value="{0,number,#,###.##}"><apex:param value="{!price}"/></apex:outputText>

 

But the result of getPrice() was a string. The incorrect conversion was causing the page to display the Unathorized page - a little odd that it didn't display the Exception page since this is what's configured, but I'll leave that for another day!

 

Cheers, Ben

All Answers

benA360benA360

Problem solved - it was a bug. I had this in my page code:

 

<apex:outputText value="{0,number,#,###.##}"><apex:param value="{!price}"/></apex:outputText>

 

But the result of getPrice() was a string. The incorrect conversion was causing the page to display the Unathorized page - a little odd that it didn't display the Exception page since this is what's configured, but I'll leave that for another day!

 

Cheers, Ben

This was selected as the best answer
lenaShlenaSh

Hi Ben,

 

I was wondering if you could share how it is that you set up a visualforce page for public access?  Sorry, i am somewhat new to salesforce.

 

Thank you!

BulentBulent
Book: Force Platform Developer Guide Chapter 14 shows how to expose an application on Force.com Sites
Curious_GCurious_G

Hi Bulent,

 

After following Chapter 14, I can open an application page and create new records if I am logged in. If I am not, the system response is:

 

"Authorization Required

You must first log in or register before accessing this page.
If you have forgotten your password, click Forgot Password to reset it."

 

What has to be changed to avoid the need for login? Is writing the custom controller instead of standard controller extension the only option?

BulentBulent

nothing is changed to cause this. You might want to check the related FLS, object access etc. Summer'10 you'll be able to use the "Preview as Admin" feature to see the details behind these kind of errors easily.

Curious_GCurious_G

Thanks, Bulent. Will wait.

 

But yet, generally, is standard controller extension running in system mode? And what does FLS stand for?

 

Thanks again.

BulentBulent

no they don't run in system mode. so you need to check you sharing setup to make sure your site has access to the records that you are planning to show.

 

FLS= Field Level Security

Curious_GCurious_G

Thank you much, Bulent. It will keep me running for a while.

 

Best regards,