You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a user id = 1.
The created user should have a permission equal to users:*:1.
Actual behavior
The created user has a permission equal to users:*:id.
Solution
The issue happens because as a before create hook, the setPermissions hook doesn't have access to the user id (the user hasn't been created yet), thus it cannot replace it on the template.
Using the setPermissions hook as an after create hook works correctly.
The solution is to simply check if the hook is being used as a before create hook, and warn the user accordingly (as a before update or before patch hook it works correctly).
System configuration
Module versions:
I'm using the latest commit from the feathers-permissions filters branch (commit no. b33fcdb).
NodeJS version: 6.9.4
The text was updated successfully, but these errors were encountered:
Steps to reproduce
1- Add the setPermissions hook as a before create hook to the
users
service, with a template permission using the:id
string.2- Create an user by calling the
users
service.Expected behavior
Given a user id = 1.
The created user should have a permission equal to
users:*:1
.Actual behavior
The created user has a permission equal to
users:*:id
.Solution
The issue happens because as a before create hook, the setPermissions hook doesn't have access to the user id (the user hasn't been created yet), thus it cannot replace it on the template.
Using the setPermissions hook as an after create hook works correctly.
The solution is to simply check if the hook is being used as a before create hook, and warn the user accordingly (as a before update or before patch hook it works correctly).
System configuration
Module versions:
I'm using the latest commit from the feathers-permissions filters branch (commit no. b33fcdb).
NodeJS version: 6.9.4
The text was updated successfully, but these errors were encountered: