mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-22 13:37:29 +00:00
🎏🍥 Checkpoint
./server.js:933874/6243
This commit is contained in:
parent
9f3e0aa3b1
commit
d3c87768d6
20
server.js
20
server.js
@ -43,18 +43,20 @@ app.get("/status", (req, res) => {
|
|||||||
const auth = {
|
const auth = {
|
||||||
login: process.env.MATRIXUSERNAME,
|
login: process.env.MATRIXUSERNAME,
|
||||||
password: process.env.MATRIXPASSWORD
|
password: process.env.MATRIXPASSWORD
|
||||||
};
|
};
|
||||||
|
|
||||||
// parse login and password from headers
|
// parse login and password from headers
|
||||||
const b64auth = (req.headers.authorization || "").split(" ")[1] || "";
|
const b64auth = (req.headers.authorization || "").split(" ")[1] || "";
|
||||||
const [login, password] = new Buffer(b64auth, "base64").toString().split(":"); // won't work as we use : in username…
|
const [_, login, password] = new Buffer(b64auth, 'base64').toString().match(/(.*):(.*)/) || []; // slightly modified as
|
||||||
|
if (
|
||||||
if (!login || !password || login !== auth.login || password !== auth.password) {
|
!login ||
|
||||||
// Access granted...
|
!password ||
|
||||||
}
|
login !== auth.login ||
|
||||||
|
password !== auth.password
|
||||||
if (req.query.password !== process.env.PASSWORD) {
|
) {
|
||||||
return res.sendStatus(401);
|
console.log(login, password)
|
||||||
|
res.set("WWW-Authenticate", 'Basic realm="Authentication required"');
|
||||||
|
return res.status(401).send("Authentication required.");
|
||||||
}
|
}
|
||||||
fuzIsOpen = req.query.fuzisopen == "1";
|
fuzIsOpen = req.query.fuzisopen == "1";
|
||||||
lastSeen = new Date();
|
lastSeen = new Date();
|
||||||
|
Loading…
Reference in New Issue
Block a user