Fix user roles and owner permission checks #6008
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #6002
Impact: minor
Type: bugfix
Issue
addAccountToGroup
mutation doesn't properly handleuser
doc that has noroles
propertycreateAccount
isn't awaited and is therefore always truthyaccount.shopId
is null, which is usually the case now in 3.0.0 release, an account was not initially added to any groups.Solution
addAccountToGroup
mutation will not fail ifuser.roles
array is missingcreateAccount
is awaited so only the first user created will end up in the "owner" groupaccount.shopId
is null and a primary shop exists, the account is associated with the correct group for the primary shopAdditionally removed
addRolesToGroups
support forregisterPlugin
config, which is no longer needed. The roles list is currently stored in the reaction-admin app for all plugins. This will be implemented in a better way with the new authorization service.Breaking changes
If your plugin passes
addRolesToGroups
option toregisterPlugin
, it's now ignored.Testing
I suggest just code review plus testing the basic user reg/login/logout flows in conjunction with testing reactioncommerce/reaction-admin#171