MD5 in password web access

This commit is contained in:
Daniel Herrero 2018-02-15 14:35:04 +01:00
parent 505ff1dcfe
commit 754cfbc7b0
1 changed files with 9 additions and 0 deletions

View File

@ -1,7 +1,16 @@
const md5 = require('md5');
module.exports = function(Self) {
// Validations
Self.validatesUniquenessOf('name', {
message: 'Ya existe un usuario con ese nombre'
});
Self.observe('before save', (ctx, next) => {
if (ctx.currentInstance && ctx.currentInstance.id && ctx.data && ctx.data.password) {
ctx.data.password = md5(ctx.data.password);
}
next();
});
};