I have the following Bookshelf model :
Bookshelf.model.extend({
tableName: 'users',
hidden: ['password']
}, {
async getBy(filter) {
return await this.query({where: filter}).fetch();
}
})
As you see, the field password is hidden (because I usually don't want it to be shown).
But, I need it to connect my user (when doing the hash comparison) :
const user = await userModel.getBy({email: req.body.email});
if (await bcrypt.compare(req.body.password, user.password)) {
// here user.password is undefined because it is hidden
}
Is there a way to shortcut the visibility plugin and get the password without having to do things like directly using knex (Bookshelf.knex.raw()) ?
Best regards,