fix(config) do not crypt password when save with sockets

This commit is contained in:
coderaiser 2014-12-01 11:45:42 -05:00
parent 3bdcf2f628
commit 6f1d49fcca

View file

@ -73,6 +73,8 @@
if (!is) {
socket.emit('err', 'Error: Wrong data type!');
} else {
cryptoPass(json);
Object.keys(json).forEach(function(name) {
data = CloudFunc.formatMsg('config', name);
set(name, json[name]);
@ -132,17 +134,12 @@
pipe.getBody(req, function(error, body) {
var data = '',
json = Util.json.parse(body) || {},
passwd = json.password,
sha = crypto.createHash('sha512WithRSAEncryption');
json = Util.json.parse(body) || {};
if (error) {
if (error)
callback(error);
} else if (passwd) {
sha.update(passwd);
passwd = sha.digest('hex');
json.password = passwd;
}
else
cryptoPass(json);
Object.keys(json).forEach(function(name) {
data = CloudFunc.formatMsg('config', name);
@ -158,4 +155,19 @@
});
}
function cryptoPass(json) {
if (json && json.password)
json.password = crypt(json.password);
}
function crypt(password) {
var result,
sha = crypto.createHash('sha512WithRSAEncryption');
sha.update(password);
result = sha.digest('hex');
return result;
}
})();