Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove canInviteToGroup helper on the client #214

Merged
merged 2 commits into from
Feb 12, 2020

Conversation

kieckhafer
Copy link
Member

Resolves #211
Impact: minor
Type: bugfix

Issue

Issue Description

After creating your first user, if you click on "Accounts" the screen is blank and it throws this error in the console:

TypeError: Cannot read property 'ixKfbghjg9tYLX9BZ' of undefined
    at Object.canInviteToGroup (5650109b78b2a3b0e1a28555f19526d48d064113.js?meteor_js_resource=true:959)
    at 5650109b78b2a3b0e1a28555f19526d48d064113.js?meteor_js_resource=true:959
    at Array.filter (<anonymous>)
    at Reaction(GroupsTableCell) (5650109b78b2a3b0e1a28555f19526d48d064113.js?meteor_js_resource=true:959)

Solution

Remove the UI / client helper canInviteToGroup. This helper was checking permissions in a way we no longer support in v3.0.0.

This solution relies on the API's server side permissions checks to determine if a user has the correct permissions to perform an action. The client can be updated in the future to provide a pre-action warning / error / restriction, if desired.

Breaking changes

Any custom code that uses Reaction.canInviteToGroup helper will need to be updated tor remove that helper.

Testing

  1. Create an account and a shop
  2. See that you can view the Accounts page.
  3. See that you can invite a user when you are an admin / have the correct permissions
  4. See that you get a server error when you are not an admin / don't have the correct permissions

Signed-off-by: Erik Kieckhafer <ek@ato.la>
Signed-off-by: Erik Kieckhafer <ek@ato.la>
@kieckhafer
Copy link
Member Author

@mikemurray @willopez see the discussion in #211 as to whether this is the appropriate fix.

Copy link
Member

@willopez willopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Starting with a fresh db and registering a new user and creating a shop and then I click on the accounts menu item and get this error:

main.js:178 Uncaught TypeError: Cannot read property 'some' of undefined
    at roleCheck (main.js:178)
    at Object.hasPermission (main.js:216)
    at Object.hasAdminAccess (main.js:263)
    at hoc.js:91
    at tracker.js:40
    at Computation._compute (tracker.js:308)
    at new Computation (tracker.js:206)
    at Object.Tracker.autorun (tracker.js:576)
    at tracker.js:38
    at Object.Tracker.nonreactive (tracker.js:603)```

@kieckhafer
Copy link
Member Author

@willopez I think that's the same issue you were seeing in this ticket. Does it work if you refresh? If so, lets keep that a separate issue.

@willopez
Copy link
Member

Yes, refreshing it "fixes" the issue. @aldeed was going to look at a way to refresh the user, any updates on this Eric?

@aldeed
Copy link
Contributor

aldeed commented Feb 12, 2020

@willopez No but I agree that's a separate issue that should not hold back this PR

Copy link
Member

@willopez willopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kieckhafer kieckhafer merged commit ee0e31f into trunk Feb 12, 2020
@kieckhafer kieckhafer deleted the fix-kieckhafer-accountsAdminPanel branch February 12, 2020 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Accounts screen is blank and throws error after shop creation
3 participants