19 replies [Last post]
wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11

Hello,
Hopefully this is the right place for this post, I've read through the documentation on this site and I tried searching the forums for any similar issues but couldn't find any reference to my problem.

I've been having problems viewing products that I've created when not logged in with admin rights. After enabling/disabling each permission one-by-one in the user management section, I've narrowed it down to the "administer nodes" permission, it seems like I can only view products if this is enabled. Otherwise, I'll get an "Access denied, You are not authorized to access this page." Has anyone else experienced this? Any ideas on why this is happening, or tips on how to remedy this issue?

Versions I'm running:
drupal 5.3
ubercart 5.x-1.0-alpha8

Thanks,
Wes

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Product nodes not showing if administer nodes not enabled fo

On the livetest, anonymous users only have the 'access content' permission, plus search. Having 'administer nodes' will override not having 'access content', so make sure that is enabled for everyone you want to see your products.

wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11
Re: Re: Product nodes not showing if administer nodes not enable

Thanks for your response.

This doesn't seem to be the case on my test site. I've had "access content" enabled for anonymous. I just did a test where I created a new role with every permission enabled except "administer nodes." when I log in with a user that has that role, I still cannot see the products. however, once I enable that one permission, then the products will show up.

This only happens with the products, I don't have problems accessing nodes that are of other types.

I'm not familiar with the drupal code, do you know where in the code it checks whether or not to display a node? Maybe I'll be able to see what is causing this condition to fail?

wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11
Re: Re: Re: Product nodes not showing if administer nodes not en

And to clarify, I only get the "access denied" if I try to go directly to a product node manually. If I go to the catalog, it will show up empty.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Re: Re: Product nodes not showing if administer nodes not en

The function to look for is node_access() in the node.module file. It uses the hook_access() that is implemented in several modules.

wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11
Re: Re: Re: Re: Product nodes not showing if administer nodes no

Ok, so I'm taking a look at the node_access() function calls for a product node. It looks like it's failing when it's calling the hook_access() for the uc_product module. Via some var_dump() calls I see that node_access is calling module_invoke() three times, with the $module and $op parameters and the returned value of module_invoke() as:

"uc_product" "view" returns NULL
"uc_product" "update" returns bool(FALSE)
"uc_product" "delete" returns bool(FALSE)

If I look at the uc_product.module's uc_product_access(), it doesn't have a case statement for 'view', it only has cases for 'create', 'update', and 'delete'. Is this how it is supposed to be or should there be an entry for 'view'? If I do manually set this case to TRUE it does seem to work.

Lyle's picture
Offline
AdministratoreLiTe!
Joined: 08/07/2007
Juice: 6841
Re: Re: Re: Re: Re: Product nodes not showing if administer node

The idea is that other modules, especially those that deal with the node_access table should get a chance to determine if someone can have access to the node. If uc_product specifies true or false in every case, it would override any rules that would be set up there.

Maybe that's the problem. When Drupal is installed, the node_access table has one row to grant access to all nodes to everybody:

nid gid realm grant_view grant_update grant_delete
0 0 all 1 0 0

Check your node_access table to see if it looks like this. If you've used any modules that affect access, they might have been configured badly.

wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11
Re: Re: Re: Re: Re: Re: Product nodes not showing if administer

Perhaps this has something to do with it. I don't have an entry for nid==0, but I do have entries starting at 1. However, it looks like the nid's that are my products don't have any entries in this node_access table. Am I right to assume that every node in the node table should have an entry in the node_access table? Interestingly, I've tried creating some other content that is not related to ubercart, and I'm having the same issue with that as well, no entry get created in the node_access table which I guess gives me the "access denied" error.

So I guess this may be more a drupal issue than ubercart.

wcleong's picture
Offline
Joined: 12/17/2007
Juice: 11
Re: Re: Re: Re: Re: Re: Re: Product nodes not showing if adminis

Looks like I've gotten things working again! Somehow my node_access table must have gotten corrupted (not sure how that happened), but I just tried rebuilding my permissions with:
Administer › Content management > Post Settings > Rebuild Permissions

And that seems to have solved it, the node_access table is now populated with the one entry that you mentioned above, with nid of '0'.

Lyle, Thanks for taking the time to help me get to the bottom of this problem!
Wes

cedarm's picture
Offline
Bug FinderGetting busy with the Ubercode.
Joined: 08/29/2008
Juice: 100
Is there a bug?

I recently had to deal with a similar (reverse) problem in one of our custom modules. I was not the original author of the module, so I can't comment about why this is the case, but here's what happened.

Everything is fine, node access works, node viewing is restricted. Someone edits the node under access control and submits. Node access then doesn't work, allowing anyone to access that node. Rebuilding permissions fixes it. Any further editing "un-fixes"/breaks the edited node.

I fixed the first bug and created a second bug: node access works, node viewing is restricted. Disable the module, then re-enable it. Same as above, node access then doesn't work, allowing anyone to access the node.

Then I fixed them both. hook_node_access_records() has "strange" consequences if you don't understand it well. This function is called during at least two different operations, module enable (or disable, I forget), and node update. In my module, during enable/disable $node was a stdClass object. During node update $node was an array. The code wasn't written to handle both cases, so it barfed, corrupting the node access table. The final fix had to handle both cases.

May I suggest that perhaps Ubercart has or had a similar bug? Does anyone know if this has been investigated and/or fixed? IMHO it's worth tracking down and fixing, rather than just telling users to rebuild permissions. The recent post by decibel.places suggests that a bug still exists.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: Is there a bug?

Can you post or tell us what the custom module is? I haven't experienced this issue but I don't use any node access modules at the moment. But it sounds like it's a bug in your custom code which possibly is allowing different access levels for "admin" users?

--
Help directly fund development: Donate via PayPal!

cwcart's picture
Offline
Joined: 12/11/2008
Juice: 27
I think bug still exists

Hi,

i setup an ubercart 2.0-dev store and every thing is fine for users with "Administer nodes" permissions, but it doesn't work for others (2), and i do not want to open "Administer nodes" perm to everybody.

my product node is well defined in node_access table, and i tried as well to Rebuild Permissions several times.

but registered users (2) or anonymous can not see content of catalog nor terms, and direct link to products gives an access denied !

i am still stunned by this issue.

Hearing for any idea or bug fix.

Thank you

gargsuchi's picture
Offline
Joined: 10/21/2009
Juice: 7
Heres my fix

Run this query
insert into node_access values (0, 0, 'all', 1, 0, 0);
Now you do not need to give "administer nodes" to all users.

dafeder's picture
Offline
Joined: 03/11/2008
Juice: 42
thanks!

I was completely stumped on the same problem until I found this post. Might be worth mentioning in the User's Guide.

torgosPizza's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.
Joined: 08/14/2007
Juice: 4110
Re: thanks!

I'll be damned. I just had this issue on my dev server (not sure exactly what module caused this to happen) since I'm updating a bunch of modules here.

This is a valuable post - I would never have found that button if it weren't mentioned here. Many thanks.

--
Help directly fund development: Donate via PayPal!

theloonypin's picture
Offline
Joined: 06/09/2008
Juice: 34
search access denied

I can't find the "reset permissions" button anywhere on post settings. I'm having trouble getting users permission to access the search page, and this is the closest thread I could find.

Any ideas why they're getting "Access Denied: you are not authorized to access this page" when they go to the search page? Admin has access; nobody else does.

Thanks for any help.
amy

theloonypin's picture
Offline
Joined: 06/09/2008
Juice: 34
Re: search access denied

I've found the solution to this (like so many other questions I've had, the answer was right there in admin; I just had to find it). In case anyone else is struggling:

Admin>User Management>Access Control

There's a search module there that needs to be enabled for anonymous and authenticated users.

Really, the way Ubercart is set up, every problem I've had so far has been easy to solve, once I found the place to solve it!

Thanks for the hard work on this cart. I appreciate it!
amy

decibel.places@drupal.org's picture
Offline
Joined: 08/13/2008
Juice: 13
same problem

Ubercart 5.x-1.3 and Drupal 5.9

Only users with "administer node" can view the products - otherwise they get "access denied"

Makes admin content items available in the menu for non-admin roles... bummer

oops - I posted this b4 I saw the post about "Rebuild Permissions" - that fixed it Smiling

wireyourworld's picture
Offline
Joined: 04/07/2010
Juice: 65
Re: same problem

These fixes have not worked for me. The problem seems to be in firefox for the most part. Also, My product descriptions I can see in IE but not firefox, no matter how many times I clear cache. Any updates for Uber 2? thats what I'm using

firecentaur's picture
Offline
Joined: 08/21/2011
Juice: 6
Re: Product nodes not showing if administer nodes not enabled fo

Hi, If you are getting Access denied when trying to create a product, try this -

After browsing through my set of installed modules, I UNCHECKED
Content Permissions 6.x-2.9 Set field-level permissions for CCK fields.
Depends on: Content (enabled)

After saving, I tried to create a product by clocking on "create content" in admin, and then selecting product, and - lo and behold - it worked!