mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
fix(express) if username or password is change, auth do not work
This commit is contained in:
parent
b4eda9f9d1
commit
3347265837
1 changed files with 18 additions and 0 deletions
|
|
@ -14,6 +14,8 @@
|
|||
httpAuth = main.require('http-auth'),
|
||||
crypto = main.crypto,
|
||||
basic,
|
||||
oldPass,
|
||||
oldName,
|
||||
app = express && express();
|
||||
|
||||
exports.getApp = function(controller) {
|
||||
|
|
@ -46,10 +48,26 @@
|
|||
equal = username === name,
|
||||
sha = crypto.createHash('sha1');
|
||||
|
||||
if (!oldPass)
|
||||
oldPass = passwd;
|
||||
|
||||
if (!oldName)
|
||||
oldName = name;
|
||||
|
||||
if (!equal)
|
||||
username === oldName;
|
||||
|
||||
sha.update(password);
|
||||
hash = sha.digest('hex');
|
||||
equal = passwd === hash && equal;
|
||||
|
||||
if (!equal) {
|
||||
sha = crypto.createHash('sha1');
|
||||
sha.update(oldPass);
|
||||
hash = sha.digest('hex');
|
||||
equal = passwd === hash && equal;
|
||||
}
|
||||
|
||||
callback(equal);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue