summary refs log tree commit diff
path: root/slowcord/build/index.js
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-06-27 15:48:48 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2022-06-27 15:50:47 +1000
commit212301c62cfae662f182e3a4bdbd0692dbaeb960 (patch)
tree4dda7b0d81b3d4f187c31c382a3252ee9b256dfc /slowcord/build/index.js
parentMerge branch 'master' into slowcord (diff)
downloadserver-212301c62cfae662f182e3a4bdbd0692dbaeb960.tar.xz
Styling, login whitelists
Diffstat (limited to 'slowcord/build/index.js')
-rw-r--r--slowcord/build/index.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/slowcord/build/index.js b/slowcord/build/index.js

index 484113ed..4fcf326f 100644 --- a/slowcord/build/index.js +++ b/slowcord/build/index.js
@@ -14,6 +14,11 @@ import cookieParser from "cookie-parser"; import { initDatabase, generateToken, User, Config } from "@fosscord/util"; import path from "path"; import fetch from "node-fetch"; +// apparently dirname doesn't exist in modules, nice +/* https://stackoverflow.com/a/62892482 */ +import { fileURLToPath } from "url"; +const __filename = fileURLToPath(import.meta.url); +const __dirname = path.dirname(__filename); const app = express(); app.use(cookieParser()); const port = process.env.PORT; @@ -57,6 +62,7 @@ Discord.getUserDetails = (token) => __awaiter(void 0, void 0, void 0, function* if (!json.username || !json.email) return null; // eh, deal with bad code later return { + id: json.id, email: json.email, username: json.username, }; @@ -77,6 +83,15 @@ app.get("/oauth/:type", (req, res) => __awaiter(void 0, void 0, void 0, function const details = yield handler.getUserDetails(data.access_token); if (!details) return res.sendStatus(500); + // temp dirty solution + const whitelist = [ + "226230010132824066", + "84022289024159744", + "841745750576726057", + "398941530053672962", // erkinalp + ]; + if (whitelist.indexOf(details.id) === -1) + return res.sendStatus(403); let user = yield User.findOne({ where: { email: details.email } }); if (!user) { user = yield User.register({ @@ -89,6 +104,7 @@ app.get("/oauth/:type", (req, res) => __awaiter(void 0, void 0, void 0, function res.cookie("token", token); res.sendFile(path.join(__dirname, "../public/login.html")); })); +app.get("/app", (req, res) => res.sendStatus(200)); app.get("*", (req, res) => { res.sendFile(path.join(__dirname, "../public/login.html")); });