MD5 in password web access
This commit is contained in:
parent
505ff1dcfe
commit
754cfbc7b0
|
@ -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();
|
||||
});
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue