A user who has the "view own userpoints" permission has no access to his userpoint list (site/myuserpoints). This is because of the lines 1686 - 1690 in userpoints.module.

...
  if(!user_access(USERPOINTS_PERM_VIEW)) {
    // User has no access to view points
		drupal_access_denied();
    return;
  }
...

If i grant this user the required permission "view userpoints", he also is able to see the points of an other user, what is not the general idea.

Thanks,
dendie

Comments

braindrift’s picture

StatusFileSize
new1.06 KB

I think this patch fixes it

braindrift’s picture

Status: Active » Needs review
kbahey’s picture

StatusFileSize
new7.27 KB

Actually, I think this part is not needed:

  // Check permissions
  if(!user_access(USERPOINTS_PERM_VIEW)) {
    // User has no access to view points
    drupal_access_denied();
    return;
  }

Because a user only needs the "view own" permission to view their own points.

So, the code would look like the patch which I am attaching a patch for you to test.

Please see if that works, and if it does, I will create a new stable release with it.

braindrift’s picture

Status: Needs work » Needs review

With your patch only the owner can see the points. As admin I want also be able to see the points of other user. Furthermore I would like to give the permission to see all points to a specific role.

So I think the

user_access(USERPOINTS_PERM_VIEW)

ist needed, but not at this place.

braindrift’s picture

Status: Needs review » Needs work
braindrift’s picture

The other thing is the code on line 178:

  if ($user->uid === 1 || user_access('USERPOINTS_PERM_ADMIN')) {
    return TRUE;
  }

I thik it should be:

  if ($user->uid === 1 || user_access(USERPOINTS_PERM_ADMIN)) {
    return TRUE;
  }

without the quotes.

braindrift’s picture

Status: Needs review » Needs work

Actually I think the points of an other user shold not be accessible threw the path 'myuserpoints'. A better way would be the path 'user/%user/userpoints' or somthink like that.

Thanks
dendie

kbahey’s picture

StatusFileSize
new8.49 KB

Here is another patch. I fixed the single quote issue, and more importantly allowed access to *my* to only the user himself, or a user that has admin userpoints permission.

Please test this and let me know.

braindrift’s picture

Hello, thanks for the work. Unfortunately I will be able to test it only on wednesday but the code looks good.

kbahey’s picture

Status: Needs work » Needs review

Post here when you test it. We can wait a few days.

braindrift’s picture

StatusFileSize
new2.53 KB

Hello kbahey,

I have tested it and discovered that the user needs to have the 'view userpoints' permissen when he wants to view only the own points.

Why don't you like my patch from comment #1. I think the access control should be like this:

'view own userpoints' - to view own userpoints
'view userpoints' - to view userpoints of other users

this two permissions should (could) be independent form each other.

userpoints_access_my_points should look like this:

function userpoints_access_my_points() {
  global $user;

  // User is uid 1, or has admin permission on userpoints
  if ($user->uid === 1 || user_access(USERPOINTS_PERM_ADMIN)) {
    return TRUE;
  }

  if (_userpoints_user_exists($user->uid)) {
    // User does exist
    if (user_is_logged_in() && (user_access(USERPOINTS_PERM_VIEW) || user_access(USERPOINTS_PERM_VIEW_OWN))) {
      // User has access to view points
        return TRUE;
    }
  }
}

Furthermore I do not understand why you perform access-checks in the function userpoints_list_my_userpoints. At this point all the access-checks shoud allready be checked by the userpoints_access_my_points-function.

I suggest to use this patch.

Thanks
dendie

kmillecam’s picture

userpoints-02.patch restores functionality that I need.

I need users (administrators) with the "view userpoints" permission to be able to view other user's transaction history for auditing purposes.

This patch worked for me.

Kevin

Pedro J. Fernandez’s picture

#11 works for me too.

Chad_Dupuis’s picture

+1 for the patch in #11 works as expected.....

lagerassassin’s picture

This is what hacks me off a bit about Drupal if I'm honest, NO ONE EVER puts things in laymens terms to help users that aren't familiar with things like php etc, now its totally great that this has a fix and I really want to use it but simply cant as I have no idea where to paste that code into my existing module due to a lack of knowledge with php.

Maybe someone with a bit of understanding can help us PHP "noobs" out a bit

braindrift’s picture

Hello lagerassassin,

the patch in #11 is nothing you can simply paste in the code. You have to apply this patch with a tool like eclipse. But it sounds like you are not a developer so I suggest to follow this http://drupal.org/patch/apply instuctions.

Regards,
dendie

braindrift’s picture

StatusFileSize
new64.37 KB

Here is the patched userpoints.module file which you can paste into the userpoints directory and test the patch (don't forget to rename it from userpoints.module.txt to userpoints.module)

lagerassassin’s picture

Thanks for your quick reply Dendie, no you are right I am not a developer and struggle with php, I just think its a shame because people like myself end up turning our backs on some great modules because it's so difficult to understand.

I will take a look at the video attached to the instruction link you provided but I dare say that this looks and sound just as difficult and I will probably just end up deleting a another module that I really wanted to use because I cant get it to work correctly :(

lagerassassin’s picture

WOW thanks, thats so much more the kind of thing us noobs need lol, thanks ever so much for your help and I will give it a try :)

lagerassassin’s picture

Ok, I don't know what I'm doing wrong, Ive enabled permissions for all users to see userpoints/list/all and added your patched userpoints.module and a fixed zip of userpoints_top_contributors and Im still getting the same damned page when an anon or registered user tries to access it

ACCESS DENIED

any ideas what I'm doing wrong?

braindrift’s picture

is it possible that the user has no points yet? I just tried it and got the access denied. Now I gave the user some points and now it works

lagerassassin’s picture

Thats not working, but to be honest all I need is the page userpoints/list/all to be accessible to everyone as I'm running a kind of league scoreboard thing, is there not a way to give permissions to every user? I just automatically assumed that would be possible when I downloaded this module :s

braindrift’s picture

You have to give the user the permission "view userpoints".

lagerassassin’s picture

This has been enabled all along :s

Thats why I don't understand

braindrift’s picture

Just for better understanding:

You gave the permission view userpoints to the authenticated user (not only the annonymous user) and a loged in user is not yet able to access the userpoints/list/all page?

Ela’s picture

I had the same problem, users need to have a point to access: http://site.com/myuserpoints ... thank you for the patch!

kerberos’s picture

I am not sure if this is related to this or a different bug:

In Userpoints 1.1, on a user's profile page, the 'View' link under the 'User points' section contains a link of the form:

[site url]/myuserpoints/[uid]

where [uid] is the user id of the user whose profile you are viewing. The issue is that this link is visible to everyone visiting a user's profile, but the myuserpoints link only works for the user whose profile it is. So even uid 1 gets an access denied error when they follow that link on someone else's profile.

I think this link should either only be shown for the user viewing his own profile (and should just go to myuserpoints) since it is not accessible to other users. Or maybe there should be a permission for seeing someone else's userpoint details and only show the link if its either their own profile or they have that permission?

CarbonPig’s picture

#17 - Thank Dendie - That makes things really easy! Works Great - Only problem is that I don't see a userpoints tab in the user accounts, but this might be a different issue.

kbahey’s picture

I committed the patch in #30 here #362119: "Access denied" for userpoint details. Please wait for about 12 hours before downloading and then testing it.

Please report back if we still need this one, or we just mark it as duplicate.

smokris’s picture

Status: Needs review » Closed (duplicate)

The committed patch solves the problem for me. I think we can call this issue a duplicate.

mstef’s picture

Status: Closed (duplicate) » Active

Not sure if this is a duplicate. The patch is about viewing point details.

Why do I get an access denied when trying to view my own points (/myuserpoints) if I don't have any points let. It seems very pointless and annoying because menu items won't show. The page should just say 'you dont have any points yet'...

Has that been addressed yet?

berdir’s picture

Title: Access denied to my userpoints » Access denied to my userpoints if user has no points
Version: 6.x-1.1 » 6.x-1.x-dev
Component: Code: userpoints_basic » User interface

This is something that has been addressed in the 7.x-1.x port, I'll try to create a patch to backport this soon.

BenK’s picture

@Berdir: I'm not sure if we actually fixed this yet in the D7 port (although you would know better than me). I pointed out the issue here:

http://drupal.org/node/637584#comment-3184730

(See item C)

And you responded to it here:
http://drupal.org/node/637584#comment-3216396

So unless you fixed it later (which you might have done), it looks like we may have postponed the issue since it was an existing issue in the 6.x version and we were focused on porting the existing code.

That being said, this thread might be a great opportunity to finally fix this (both in D7 and D6).

Let me know if I'm right or wrong about all of this. As always, I'm happy to test! ;-)

--Ben

berdir’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new803 bytes

You are right of course, I confused user_relationships and userpoints.

Anyway, here is a patch for D7.

BenK’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, Berdir! The patch in #34 works great. This is ready to be committed! :-)

mstef’s picture

Anything for D6?

berdir’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new852 bytes

Commited the patch against 7.x-1.x, attaching a backport for D6.

berdir’s picture

Version: 7.x-1.x-dev » 6.x-1.x-dev

Forgot to change the version.

Bilmar’s picture

Status: Needs review » Reviewed & tested by the community

Hello,

The patch fixes the issue of 'Access denied' for /myuserpoints when the user has no points.
Tested with an authenticated user on my site who has no userpoints.

/myuserpoints before the patch screengrab
/myuserpoints after the patch screengrab
permissions page screengrab

It would be nice to have "Points for username" at /myuserpoints to show the themed username, but that is a feature request different from this issue =)

Thanks Berdir!

berdir’s picture

Priority: Critical » Major

Thanks for testing, I agree that would be useful, can you open a feature request and postpone it on #556910: Menu router items: Allow to pass PASS_THROUGH to t()? Because that issue will allow to set the title through a title callback function.

berdir’s picture

Issue tags: +userpoints backport

Tagging to make it easier to find patches like this one.

dmetzcher’s picture

I can confirm that the patch for the Drupal 6 version of this module (comment #37) works. Thanks!

ionmedia’s picture

i have no ssh for patch it in my hosting, can anyone put here patched file ?

mile23’s picture

The patch in #37 didn't apply cleanly to 6.x-1.1, so here are two things:

1) userpoints.module with the patch applied (file extension set to .txt so it can be uploaded...)
2) A patch generated against 6.x-1.1 that should apply cleanly. This patch should also work against dev.

mile23’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new568 bytes

Oops... Doesn't play well with dev.

berdir’s picture

berdir’s picture

Status: Needs review » Fixed

Thanks, commited.

Status: Fixed » Closed (fixed)
Issue tags: -userpoints backport

Automatically closed -- issue fixed for 2 weeks with no activity.