mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
refactor(auth) init: add algo
This commit is contained in:
parent
83db9f078b
commit
56a7c49cbc
1 changed files with 4 additions and 3 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue