HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Check a Specific User's Junction Permissions

To check if the currently logged-in user has a certain permission for at least one junction, you can use: Gdn::session()->checkPermission('Vanilla.Discussions.Add', true, 'Category', 'any');.

However, this only returns the result for the currently logged-in user. I would like to do the same thing for a specific user object/ID instead.

There's a UserModel method Gdn::userModel()->checkPermission($User, $Permission, $Options) (view on GitHub), but junction permission checking hasn't been implemented in this method yet as of Vanilla 2.2.1 (and 2.3b1) and noted with the line // TODO: Check for junction table permissions.

Is there another method already written within Vanilla 2.2.1 to do this?

Add Pages to Vanilla with the Basic Pages app

Comments

  • R_JR_J Ex-Fanboy Munich Admin

    Could you use PermissionModels getUserPermissions() for it?

    It takes a junction table. And maybe you can use the LimitToSuffix parameter to accept the complete permission name...

  • @R_J, thanks for the suggestion! PermissionModel's getUserPermissions() does the trick with some extra processing of the array it returns. Still, it's good to use as a workaround for now. =)

    Add Pages to Vanilla with the Basic Pages app

Sign In or Register to comment.