refactor(auth) init: add algo

This commit is contained in:
coderaiser 2015-03-24 05:36:14 -04:00
parent 83db9f078b
commit 56a7c49cbc

View file

@ -32,11 +32,11 @@
var auth = httpAuth.basic({
realm: 'Cloud Commander'
}, function (username, password, callback) {
var hash,
var hash, sha,
name = config('username'),
pass = config('password'),
equal = username === name,
sha = crypto.createHash('sha512WithRSAEncryption');
algo = 'sha512WithRSAEncryption';
if (!oldPass)
oldPass = pass;
@ -47,13 +47,14 @@
if (!equal)
username === oldName;
sha = crypto.createHash(algo);
sha.update(password);
hash = sha.digest('hex');
equal = pass === hash && equal;
if (!equal) {
sha = crypto.createHash('sha512WithRSAEncryption');
sha = crypto.createHash(algo);
sha.update(oldPass);
hash = sha.digest('hex');
equal = pass === hash && equal;