mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
fix(config) do not crypt password when save with sockets
This commit is contained in:
parent
3bdcf2f628
commit
6f1d49fcca
1 changed files with 21 additions and 9 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue