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

Add role validation to USer creator #35

Closed
neural9 opened this issue May 18, 2019 · 1 comment
Closed

Add role validation to USer creator #35

neural9 opened this issue May 18, 2019 · 1 comment

Comments

@neural9
Copy link

neural9 commented May 18, 2019

When creating a user, if you don't use an expected role from the user model enum then it crashes out with:

(node:8996) [DEP0106] DeprecationWarning: crypto.createDecipher is deprecated.
warning.js:27
TypeError: Cannot read property 'toObject' of undefined
at /Users/rob/Documents/Projects/oped/oped/app/controllers/users.js:42:43
at /Users/rob/Documents/Projects/oped/oped/node_modules/mongoose/lib/model.js:4732:16

To solve, add:

.isIn(['admin', 'user','superuser'])
.withMessage('USER_NOT_IN_KNOWN_ROLE'),

to the user validation in users.validate.js.

Thanks,

Rob

@davellanedam
Copy link
Owner

Hi Rob, thank you, just fixed in v.6.1.13. Also made a test for it.

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

No branches or pull requests

2 participants