From 3d27c26699c21c9cd31595a20a5488d67fee69fd Mon Sep 17 00:00:00 2001 From: River198 Date: Sat, 12 Nov 2022 07:47:53 +0000 Subject: [PATCH 1/2] Fix connection --- dashboard/app.js | 129 +++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 65 deletions(-) diff --git a/dashboard/app.js b/dashboard/app.js index f2202c7d9..d83f8dfee 100644 --- a/dashboard/app.js +++ b/dashboard/app.js @@ -1,74 +1,73 @@ const config = require("@root/config"), - utils = require("./utils"), - CheckAuth = require("./auth/CheckAuth"); + utils = require("./utils"), + CheckAuth = require("./auth/CheckAuth"); module.exports.launch = async (client) => { - /* Init express app */ + /* Init express app */ - const express = require("express"), - session = require("express-session"), - MongoStore = require("connect-mongo"), - path = require("path"), - app = express(); + const express = require("express"), + session = require("express-session"), + MongoStore = require("connect-mongo"), + path = require("path"), + app = express(); - /* Routers */ - const mainRouter = require("./routes/index"), - discordAPIRouter = require("./routes/discord"), - logoutRouter = require("./routes/logout"), - guildManagerRouter = require("./routes/guild-manager"); + /* Routers */ + const mainRouter = require("./routes/index"), + discordAPIRouter = require("./routes/discord"), + logoutRouter = require("./routes/logout"), + guildManagerRouter = require("./routes/guild-manager"); - client.states = {}; - client.config = config; + client.states = {}; + client.config = config; - /* App configuration */ - app - .use(express.json()) // For post methods - .use(express.urlencoded({ extended: true })) - .engine("html", require("ejs").renderFile) // Set the engine to html (for ejs template) - .set("view engine", "ejs") - .use(express.static(path.join(__dirname, "/public"))) // Set the css and js folder to ./public - .set("views", path.join(__dirname, "/views")) // Set the ejs templates to ./views - .set("port", config.DASHBOARD.port) // Set the dashboard port - .use( - session({ - secret: process.env.SESSION_PASSWORD, - cookie: { maxAge: new Date(Date.now() + 12096e5) }, - name: "AIO_connection_cookie", - resave: true, - saveUninitialized: false, - store: MongoStore.create({ - mongoUrl: process.env.MONGO_CONNECTION, - }), - }) - ) // Set the express session password and configuration - name: "connection",})) // Set the express session password and configuration - .use(async function (req, res, next) { - req.user = req.session.user; - req.client = client; - if (req.user && req.url !== "/") req.userInfos = await utils.fetchUser(req.user, req.client); - next(); - }) - .use("/api", discordAPIRouter) - .use("/logout", logoutRouter) - .use("/manage", guildManagerRouter) - .use("/", mainRouter) - .use(CheckAuth, function (req, res) { - res.status(404).render("404", { - user: req.userInfos, - currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, - }); - }) - .use(CheckAuth, function (err, req, res) { - console.error(err.stack); - if (!req.user) return res.redirect("/"); - res.status(500).render("500", { - user: req.userInfos, - currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, - }); - }); + /* App configuration */ + app + .use(express.json()) // For post methods + .use(express.urlencoded({ extended: true })) + .engine("html", require("ejs").renderFile) // Set the engine to html (for ejs template) + .set("view engine", "ejs") + .use(express.static(path.join(__dirname, "/public"))) // Set the css and js folder to ./public + .set("views", path.join(__dirname, "/views")) // Set the ejs templates to ./views + .set("port", config.DASHBOARD.port) // Set the dashboard port + .use( + session({ + secret: process.env.SESSION_PASSWORD, + cookie: { maxAge: new Date(Date.now() + 12096e5) }, + name: "Connection", + resave: true, + saveUninitialized: false, + store: MongoStore.create({ + mongoUrl: process.env.MONGO_CONNECTION, + }), + }) + ) // Set the express session password and configuration + .use(async function (req, res, next) { + req.user = req.session.user; + req.client = client; + if (req.user && req.url !== "/") req.userInfos = await utils.fetchUser(req.user, req.client); + next(); + }) + .use("/api", discordAPIRouter) + .use("/logout", logoutRouter) + .use("/manage", guildManagerRouter) + .use("/", mainRouter) + .use(CheckAuth, function (req, res) { + res.status(404).render("404", { + user: req.userInfos, + currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, + }); + }) + .use(CheckAuth, function (err, req, res) { + console.error(err.stack); + if (!req.user) return res.redirect("/"); + res.status(500).render("500", { + user: req.userInfos, + currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, + }); + }); - /* Start */ - app.listen(app.get("port"), () => { - client.logger.success("Dashboard is listening on port " + app.get("port")); - }); + /* Start */ + app.listen(app.get("port"), () => { + client.logger.success("Dashboard is listening on port " + app.get("port")); + }); }; From a0ab3cb9d5286db0c382f6b611a84f5bb06cc085 Mon Sep 17 00:00:00 2001 From: Sai Teja Madha <42540377+saiteja-madha@users.noreply.github.com> Date: Sat, 12 Nov 2022 01:02:04 -0700 Subject: [PATCH 2/2] Update styling --- dashboard/app.js | 128 +++++++++++++++++++++++------------------------ 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/dashboard/app.js b/dashboard/app.js index d83f8dfee..b1dda6871 100644 --- a/dashboard/app.js +++ b/dashboard/app.js @@ -1,73 +1,73 @@ const config = require("@root/config"), - utils = require("./utils"), - CheckAuth = require("./auth/CheckAuth"); + utils = require("./utils"), + CheckAuth = require("./auth/CheckAuth"); module.exports.launch = async (client) => { - /* Init express app */ + /* Init express app */ - const express = require("express"), - session = require("express-session"), - MongoStore = require("connect-mongo"), - path = require("path"), - app = express(); + const express = require("express"), + session = require("express-session"), + MongoStore = require("connect-mongo"), + path = require("path"), + app = express(); - /* Routers */ - const mainRouter = require("./routes/index"), - discordAPIRouter = require("./routes/discord"), - logoutRouter = require("./routes/logout"), - guildManagerRouter = require("./routes/guild-manager"); + /* Routers */ + const mainRouter = require("./routes/index"), + discordAPIRouter = require("./routes/discord"), + logoutRouter = require("./routes/logout"), + guildManagerRouter = require("./routes/guild-manager"); - client.states = {}; - client.config = config; + client.states = {}; + client.config = config; - /* App configuration */ - app - .use(express.json()) // For post methods - .use(express.urlencoded({ extended: true })) - .engine("html", require("ejs").renderFile) // Set the engine to html (for ejs template) - .set("view engine", "ejs") - .use(express.static(path.join(__dirname, "/public"))) // Set the css and js folder to ./public - .set("views", path.join(__dirname, "/views")) // Set the ejs templates to ./views - .set("port", config.DASHBOARD.port) // Set the dashboard port - .use( - session({ - secret: process.env.SESSION_PASSWORD, - cookie: { maxAge: new Date(Date.now() + 12096e5) }, - name: "Connection", - resave: true, - saveUninitialized: false, - store: MongoStore.create({ - mongoUrl: process.env.MONGO_CONNECTION, - }), - }) - ) // Set the express session password and configuration - .use(async function (req, res, next) { - req.user = req.session.user; - req.client = client; - if (req.user && req.url !== "/") req.userInfos = await utils.fetchUser(req.user, req.client); - next(); - }) - .use("/api", discordAPIRouter) - .use("/logout", logoutRouter) - .use("/manage", guildManagerRouter) - .use("/", mainRouter) - .use(CheckAuth, function (req, res) { - res.status(404).render("404", { - user: req.userInfos, - currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, - }); - }) - .use(CheckAuth, function (err, req, res) { - console.error(err.stack); - if (!req.user) return res.redirect("/"); - res.status(500).render("500", { - user: req.userInfos, - currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, - }); - }); - - /* Start */ - app.listen(app.get("port"), () => { - client.logger.success("Dashboard is listening on port " + app.get("port")); + /* App configuration */ + app + .use(express.json()) // For post methods + .use(express.urlencoded({ extended: true })) + .engine("html", require("ejs").renderFile) // Set the engine to html (for ejs template) + .set("view engine", "ejs") + .use(express.static(path.join(__dirname, "/public"))) // Set the css and js folder to ./public + .set("views", path.join(__dirname, "/views")) // Set the ejs templates to ./views + .set("port", config.DASHBOARD.port) // Set the dashboard port + .use( + session({ + secret: process.env.SESSION_PASSWORD, + cookie: { maxAge: new Date(Date.now() + 12096e5) }, + name: "Connection", + resave: true, + saveUninitialized: false, + store: MongoStore.create({ + mongoUrl: process.env.MONGO_CONNECTION, + }), + }) + ) // Set the express session password and configuration + .use(async function (req, res, next) { + req.user = req.session.user; + req.client = client; + if (req.user && req.url !== "/") req.userInfos = await utils.fetchUser(req.user, req.client); + next(); + }) + .use("/api", discordAPIRouter) + .use("/logout", logoutRouter) + .use("/manage", guildManagerRouter) + .use("/", mainRouter) + .use(CheckAuth, function (req, res) { + res.status(404).render("404", { + user: req.userInfos, + currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, + }); + }) + .use(CheckAuth, function (err, req, res) { + console.error(err.stack); + if (!req.user) return res.redirect("/"); + res.status(500).render("500", { + user: req.userInfos, + currentURL: `${req.protocol}://${req.get("host")}${req.originalUrl}`, + }); }); + + /* Start */ + app.listen(app.get("port"), () => { + client.logger.success("Dashboard is listening on port " + app.get("port")); + }); };