Trying to view a user without permission should not show an error

Description

The permission users.item.get is required in order to fetch details of an individual user, as is required at URLs such as http://localhost:3000/users/view/31CD3EF0-F17F-4B31-9FEE-B4FBC44B61EE/verner?filters=active.Active%2Cactive.Inactive&sort=Active which causes Stripes to GET http://localhost:9130/users/31CD3EF0-F17F-4B31-9FEE-B4FBC44B61EE

The UI should avoid making this call if it knows (due to the absence of the necessary permission) that the request will fail. (One reason is that it saves the user from seeing a frightening popup) – instead, the message in the right pane ("Sorry - your user permissions do not allow access to this page.") should be the only indication that something is wrong.

CSP Request Details

None

CSP Rejection Details

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Mike Taylor April 26, 2017 at 2:47 PM

Oh, no need – I can just do the permission checking, and issue the message for the right pane, in the top-level component.

Mike Taylor April 26, 2017 at 2:34 PM

First try: protecting the <Route> component inside <IfPermission>. That works, but of course it prevents the route being interpreted at all, so that the right pane doesn't display the "you don't have permission" message.

Instead, I think I am going to need to introduce a wrapper component whose only job is to check the permission, then render either the no-perms message of the real <ViewUser>.

Mike Taylor April 26, 2017 at 9:25 AM

This is how we handle other permission-failure avoidances in the Users module:

<IfPermission {...this.props} perm="circulation.loans.collection.get"> <this.connectedUserLoans onClickViewLoansHistory={this.onClickViewLoansHistory} {...this.props} /> </IfPermission>

That trivial approach will not work here, as the <ViewUser> component is invoked by a React route rather than by direct inclusion.

Done

Details

Assignee

Reporter

Labels

Priority

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created April 26, 2017 at 9:23 AM
Updated April 26, 2017 at 3:01 PM
Resolved April 26, 2017 at 3:01 PM
TestRail: Cases
TestRail: Runs

Flag notifications