fix(password) createHash: algo could be undefined

This commit is contained in:
coderaiser 2016-02-10 04:05:09 -05:00
parent 015ae51b19
commit 053f9d2ff9
2 changed files with 6 additions and 5 deletions

View file

@ -36,7 +36,7 @@
algo = config('algo');
sameName = username === name;
samePass = pass === cryptPassword(algo, password);
samePass = pass === cryptPassword(password, algo);
callback(sameName && samePass);
}

View file

@ -3,13 +3,14 @@
var crypto = require('crypto');
module.exports = function(algo, password) {
module.exports = function(password, algo) {
var result, sha;
if (!password) {
password = algo;
if (!password)
throw Error('password could not be empty!');
if (!algo)
algo = 'sha512WithRSAEncryption';
}
sha = crypto.createHash(algo);