fix: lint errors
This commit is contained in:
parent
eaa4b1ebaa
commit
34ae8e42f3
|
@ -37,6 +37,32 @@ const {
|
||||||
|
|
||||||
const requiresPassword = !!PASSWORD || !!PASSWORD_HASH;
|
const requiresPassword = !!PASSWORD || !!PASSWORD_HASH;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if `password` matches the PASSWORD_HASH.
|
||||||
|
*
|
||||||
|
* For backward compatibility it also allows `password` to match the clear text PASSWORD,
|
||||||
|
* but only if no PASSWORD_HASH is provided.
|
||||||
|
*
|
||||||
|
* If both enviornment variables are not set, the password is always invalid.
|
||||||
|
*
|
||||||
|
* @param {string} password String to test
|
||||||
|
* @returns {boolean} true if matching environment, otherwise false
|
||||||
|
*/
|
||||||
|
const isPasswordValid = (password) => {
|
||||||
|
if (typeof password !== 'string') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PASSWORD_HASH) {
|
||||||
|
return bcrypt.compareSync(password, PASSWORD_HASH);
|
||||||
|
}
|
||||||
|
if (PASSWORD) {
|
||||||
|
return password === PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
module.exports = class Server {
|
module.exports = class Server {
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -101,7 +127,7 @@ module.exports = class Server {
|
||||||
status: 401,
|
status: 401,
|
||||||
message: 'Incorrect Password',
|
message: 'Incorrect Password',
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
event.node.req.session.authenticated = true;
|
event.node.req.session.authenticated = true;
|
||||||
event.node.req.session.save();
|
event.node.req.session.save();
|
||||||
|
@ -239,32 +265,6 @@ module.exports = class Server {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if `password` matches the PASSWORD_HASH.
|
|
||||||
*
|
|
||||||
* For backward compatibility it also allows `password` to match the clear text PASSWORD,
|
|
||||||
* but only if no PASSWORD_HASH is provided.
|
|
||||||
*
|
|
||||||
* If both enviornment variables are not set, the password is always invalid.
|
|
||||||
*
|
|
||||||
* @param {string} password String to test
|
|
||||||
* @returns {boolean} true if matching environment, otherwise false
|
|
||||||
*/
|
|
||||||
const isPasswordValid = (password) => {
|
|
||||||
if (typeof password !== 'string') {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!!PASSWORD_HASH) {
|
|
||||||
return bcrypt.compareSync(password, PASSWORD_HASH);
|
|
||||||
}
|
|
||||||
if (!!PASSWORD) {
|
|
||||||
return password == PASSWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Static assets
|
// Static assets
|
||||||
const publicDir = '/app/www';
|
const publicDir = '/app/www';
|
||||||
app.use(
|
app.use(
|
||||||
|
|
Loading…
Reference in New Issue