Closed 0aps closed 6 years ago
@0aps
Just want to make sure you are using Sails v1? This bleeding edge of this repo (2.x versions) are for v1 only.
We have not yet updated the generator since dropping the Marlinspike dependency which broke in v1. Until then you have to manually extend every controller, model, policy, and service by putting a one line file into your api.
Here is an example of doing this without any overrides.:
api/controllers/AuthController.js:
module.exports = require('@inspire-platform/sails-hook-permissions/dist/api/controllers/AuthController');
Here is an example of a model with some overrides:
api/models/User.js
var _ = require('lodash');
var _super = require('@inspire-platform/sails-hook-permissions/dist/api/models/User');
_.merge(exports, _super);
_.merge(exports, {
attributes: {
firstName: {
type: 'string',
columnName: 'first_name',
required: true,
minLength: 1
},
lastName: {
type: 'string',
columnName: 'last_name',
required: true,
minLength: 1
}
}
});
All of this copying is a bit tedious, but we have a new pattern for loading the hook which we are using successfully in a different (unrelated) hook. This will make it unnecessary to copy controllers and services. Hopefully we will have this pattern applied to this hook by the end of the month.
Thanks for trying out the hook. Let me know if you have any more questions.
@MrMaz
Thanks for answering so quickly. Yes, I'm using Sails v1. I was about to upgrade the library myself but decided to check out the existing forks before. This seemed good enough.
I added the references to the policies and its working perfectly. Thanks for the help! Waiting for the new pattern for loading the hooks.
Regards Ángel
Hey guys, When I lift my app I get the following error:
Do you know why this happens? Seems like the policies middleware is not aware of the policies created in the package.
Regards, Ángel