Skip to content
Snippets Groups Projects
Commit 9d5f8a1b authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

check existing key on url parameter and header aswell

parent 88175fed
No related branches found
No related tags found
No related merge requests found
Pipeline #9296 passed
......@@ -77,8 +77,16 @@ router.get("/remove", (req, res) => {
});
router.get("/enter", function (req, res, next) {
if (req.cookies.key) {
Key.GET_KEY(req.cookies.key, false).then((key) => {
let key = null;
if (req.query.key) {
key = req.query.key;
} else if (req.headers.key) {
key = req.headers.key;
} else if (req.cookies.key) {
key = req.cookies.key;
}
if (key != null) {
Key.GET_KEY(key, false).then((key) => {
res.redirect(
`${res.locals.baseDir}/key/` + encodeURIComponent(key.get_key())
);
......@@ -117,7 +125,7 @@ router.post("/enter", upload.single("file"), async (req, res, next) => {
if (typeof req.body.key === "string" && req.body.key.length > 0) {
let input = req.body.key.trim();
// Login via Login code
if(input.match(/^\d{6}$/)){
if (input.match(/^\d{6}$/)) {
let prefix = "logincode:";
let code = input;
let key_from_code = await __redis_client.getdel(prefix + code);
......@@ -129,12 +137,12 @@ router.post("/enter", upload.single("file"), async (req, res, next) => {
return;
}
}
if(input.match(/^[0-9A-F]{32}$/i)){
input = [input.slice(0,8), input.slice(8,12), input.slice(12,16), input.slice(16,20), input.slice(20,32)].join("-");
if (input.match(/^[0-9A-F]{32}$/i)) {
input = [input.slice(0, 8), input.slice(8, 12), input.slice(12, 16), input.slice(16, 20), input.slice(20, 32)].join("-");
}
if(Key.IS_VALID_UUID(input) || input.match(/^[0-9a-zA-Z]{6}$/)){
if (Key.IS_VALID_UUID(input) || input.match(/^[0-9a-zA-Z]{6}$/)) {
key = await Key.GET_KEY(input).then((key) => key.get_key());
}else{
} else {
res.render("login/key", { errors: "The entered key is invalid. Please check your input." });
return;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment