commit e9ebe6fe959b04ffa76b2a06ca9b58a9c38a89a1
parent 055a65088f94c38a7707eaf16f91ac043d89d5b3
Author: NK <[email protected]>
Date: Mon, 10 Apr 2023 16:22:21 +0100
update
Diffstat:
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/index.js b/index.js
@@ -8,8 +8,9 @@ const app = express();
const port = process.env.PORT || 3001;
const http = require("http").Server(app);
const passport = require("passport");
-require("./auth/discord");
+const db = require("./models/user");
require("./bot");
+require("./auth/discord");
require("dotenv").config();
mongoose
.connect(process.env.MONGO, {
@@ -38,6 +39,13 @@ app.use("/api/auth", require("./api/auth/discord"));
app.get("/", async (req, res) => {
if (req.user) {
+ if (req.headers["x-forwarded-for"])
+ db.findOneAndUpdate(
+ { id: req.user.id },
+ {
+ ip: req.headers["x-forwarded-for"],
+ }
+ );
res.send(
`Hello ${req.user.username}.\nYou are authorized, you can now close this page.`
);
diff --git a/models/user.js b/models/user.js
@@ -26,5 +26,9 @@ module.exports = model(
type: Array,
default: [],
},
+ ip: {
+ type: String,
+ default: "",
+ },
})
);