From cc4f65bd351566e020eceaab8a6c362fe1385404 Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Tue, 19 Jan 2021 19:23:14 +0100
Subject: Added image redirect

---
 app.js | 6 ++++++
 1 file changed, 6 insertions(+)

(limited to 'app.js')

diff --git a/app.js b/app.js
index 508f0e4..7987342 100644
--- a/app.js
+++ b/app.js
@@ -2,6 +2,7 @@ require("dotenv").config();
 require("./db").init();
 const express = require("express");
 const session = require("express-session");
+const fs = require("fs").promises;
 require("log-timestamp");
 
 const { auth, checkUser, checkAdmin } = require("./auth");
@@ -39,4 +40,9 @@ app.use("/profile", checkUser, profile);
 app.use("/admin", checkAdmin, admin); // Lel
 app.use("/auth", auth);
 
+app.get("/images", checkUser, async (req, res) => {
+    const links = (await fs.readFile(__dirname + "/images.txt", "utf8")).split("\n");
+    res.redirect(links[req.session.cid - 1]);
+});
+
 app.listen(process.env.PORT || 5005, () => console.log(`Server started on http://localhost:${process.env.PORT}`));
-- 
cgit v1.2.3