Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I have two very similar VF components with actionFunctions in them. Thee components are conditionally rendered using a formula to see if the user is logged in and are not shown if the user is a guest. When I use an actionFunction in one of the components it works fine. When I add it to the other component and try to view the page as a guest I get the 'down for maintenance page'. From the debug log it looks like it's triggering the Unauthorized page, but it's unclear why.

I realize this is kind of vague, but I'm wondering if there are there some permissions issues here with actionFunctions that I'm not seeing.

share|improve this question
    
Can yoi please POST the code also that we may look into.Its a security issue –  Mohith Shrivastava Oct 5 '12 at 3:01
    
Is it possible some exception is happening in your controller, or null references in your VF binding declarations. –  Samuel De Rycke Oct 5 '12 at 9:58
    
@MohithKumar the code causing it is just a standard actionFunction tag, nothing special. –  paul Oct 5 '12 at 15:39
    
@Sdry I suppose it's possible something is happening in the controller, but I don't think so, because I can use any function as the action attribute with the exact same result. –  paul Oct 5 '12 at 15:39

5 Answers 5

up vote 4 down vote accepted

I was working on someone else's code when this bug came up - didn't realize that in the constructor for the controller of a component on the VF page, the previous coder wrote this:

if (user.usertype == 'GUEST') {
            throw new NoAccessException();
}

The component should not have been loaded in the first place, because the render condition is:

rendered="{!NOT(ISPICKVAL($User.UserType,'Guest'))}

Which is why it was hard to find & debug, because I assumed it couldn't get there.

But for some reason, when an actionFunction is inserted into the component, it bypasses the render condition and loads the component and controller, triggering this error. I'm still not sure why it's only triggered when an actionFunction is added to the component, but commenting out that line throwing the exception solves the problem.

This might be related - http://boards.developerforce.com/t5/General-Development/System-Exception-Internal-Salesforce-com-Query-Error-Diagnosis/td-p/156459

I think it's a bug in the Salesforce code, maybe specific to Sites -- I'm going to email them and see if I get a response.

Thanks for your answers!

share|improve this answer

Does the Guest profile have access to everything that the component and/or component's controller uses? You need to make sure that the Guest profile has the proper object CRUD and FLS. You get to the Guest profile by going through the Site settings and clicking the Public Access Settings button. The profile is NOT listed in the regular profile list.

So, while you may have given proper access to the VF pages and the Apex classes on the Site settings page, you still have to give the proper object permissions on the profile, itself.

As for why you get the site maintenance as opposed to the unauthorized, I believe that I've gotten the site maintenance before when my custom unauthorized page used something that the public profile didn't have access to or when that page had an error of some sort.

share|improve this answer
    
This makes sense, but the page works fine - with commandButtons and access to lots of variables in the controller - and only breaks when when I add the actionFunction and only when I add the actionFunction. And it doesn't matter what method I use as the action. If it were access to a specific object field, wouldn't it break with or without the actionFunction? or wouldn't it matter which action method the actionFunction's took? –  paul Oct 5 '12 at 20:12
    
Thanks for you help, it was something else in the code. Figured it out, answered the question - will mark answered tomorrow when I can. –  paul Oct 5 '12 at 20:48

Does the Guest User (and potentially the Site ?) have access to both Pages (VF Pages in each of the components) ?

share|improve this answer
    
Yes. It's literally isolated to the one line of code -- add the actionFunction and it goes down, remove it and it works fine. If there was no access to the page, it wouldn't show up either way. –  paul Oct 4 '12 at 21:59

When ever there is an error in the controller or the page the site shows unauthorised page .In the site settings you may check that the what are the page assignments .

Site settings>Error Pages and find if everything is assigned properly or not .

share|improve this answer
    
Thanks, yes it's assigned properly. According to the debug logs it's showing the unauthorized page, but it's actually showing the under maintenance page. –  paul Oct 5 '12 at 15:36

I had a similar problem and symptom where it would work internally (normal salesforce user), but not on sites as a guest user. After trying a combinations of items, wrapping the actionfunction with actionregion worked.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.