Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
merge dev to main (#292)
Browse files Browse the repository at this point in the history
* Don't let frontend know why 401 was sent

* Remove ratelimiter because cloudflare handles that already
  • Loading branch information
TheJeterLP authored Mar 29, 2024
1 parent 6125085 commit 2042206
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 32 deletions.
21 changes: 0 additions & 21 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"express": "^4.19.2",
"express-rate-limit": "^7.2.0",
"express-session": "^1.18.0",
"jsonwebtoken": "^9.0.2",
"jwt-decode": "^4.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/main/typescript/middlewares/authJwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ const verifyToken = (req: Request, res: Response, next: NextFunction) => {
const userId = req.session.userId;

if (token === undefined || userId === undefined || !token || !userId) {
return res.status(401).send({ message: 'Unauthorized! Session not found or expired!' });
return res.status(401).send({ message: 'Unauthorized!' });
}

jwt.verify(token, security_settings.jwt_secret, (err, decoded) => {
if (err) {
return res.status(401).send({ message: 'Unauthorized! Error: ' + err.name + ': ' + err.message });
return res.status(401).send({ message: 'Unauthorized!' });
}

const payload = decoded as JwtPayload;
if (payload.id != userId) {
return res.status(401).send({ message: 'Unauthorized! UserID from Session does not match UserID from Payload!' });
return res.status(401).send({ message: 'Unauthorized!' });
}
next();
});
Expand Down
7 changes: 0 additions & 7 deletions src/main/typescript/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Required external modules
*/
import express, { Application } from 'express';
import RateLimit from 'express-rate-limit';
import cors from 'cors';
import mongoose from 'mongoose';
import session from 'express-session';
Expand Down Expand Up @@ -39,11 +38,6 @@ import path from 'node:path';
* App Variables
*/
const app: Application = express();
const limiter = RateLimit({
// 15 minutes
windowMs: 15 * 60 * 1000,
limit: 100,
});

/**
* Database connection
Expand All @@ -59,7 +53,6 @@ app.use(cors({
origin: server_settings.frontend_url,
credentials: true,
}));
app.use(limiter);
app.use(cookies());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
Expand Down

0 comments on commit 2042206

Please sign in to comment.