Renamed file

This commit is contained in:
Shahan Nedadahandeh 2023-03-11 18:12:26 -05:00
parent e73500fb91
commit 6646ba8a25
2 changed files with 5 additions and 7 deletions

View File

@ -4,27 +4,27 @@ const app = express();
const publicDirname = path.join(__dirname, "../public");
const DEVELOPMENT_PORT = 8000;
import whiteListedUsers from "./whitelistedUser.json";
import allowedUsers from "./allowedUsers.json";
import * as dotenv from "dotenv";
import { makePullRequest } from "./giteaClient";
dotenv.config();
const devQuestId = "cdalek"
const devQuestId = "cdalek";
const validateAuthorization = (req, res, next) => {
// TODO: Replace with actual quest id from request
if (!whiteListedUsers.includes(devQuestId)) {
if (!allowedUsers.includes(devQuestId)) {
res.status(401);
res.sendFile(path.join(publicDirname, "unauthorized.html"));
} else {
return next();
}
}
};
// Validate user's quest id
app.use(validateAuthorization);
app.use(validateAuthorization);
app.get("/", async (req, res) => {
res.sendFile(path.join(publicDirname, "index.html"));
@ -36,8 +36,6 @@ app.get("/", async (req, res) => {
// Allows serving static files
app.use(express.static(publicDirname));
app.listen(DEVELOPMENT_PORT, () => {
console.log(`Listening on http://localhost:${DEVELOPMENT_PORT}`);
});