@digicms/cms
Version:
An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite
21 lines (14 loc) • 437 B
JavaScript
;
const { getOr, toNumber, isString, isBuffer } = require('lodash/fp');
const bcrypt = require('bcryptjs');
const transforms = {
password(value, context) {
const { attribute } = context;
if (!isString(value) && !isBuffer(value)) {
return value;
}
const rounds = toNumber(getOr(10, 'encryption.rounds', attribute));
return bcrypt.hashSync(value, rounds);
},
};
module.exports = transforms;