summary refs log tree commit diff
path: root/api
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-17 22:42:16 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-08-17 22:42:16 +0200
commitd8b01058b34b22ae9fba25ec9c257e62de4e067b (patch)
tree80c840398619b9a8ac8d0a7e1ab53c0b64aec676 /api
parent:sparkles: mention regex (diff)
downloadserver-d8b01058b34b22ae9fba25ec9c257e62de4e067b.tar.xz
:art: clean up
Diffstat (limited to 'api')
-rw-r--r--api/package-lock.json4
-rw-r--r--api/src/middlewares/Authentication.ts7
-rw-r--r--api/src/routes/auth/login.ts1
3 files changed, 7 insertions, 5 deletions
diff --git a/api/package-lock.json b/api/package-lock.json
index d94e3be0..00af4b5b 100644
--- a/api/package-lock.json
+++ b/api/package-lock.json
@@ -43,6 +43,7 @@
 				"@types/i18next-node-fs-backend": "^2.1.0",
 				"@types/jsonwebtoken": "^8.5.0",
 				"@types/mongodb": "^3.6.9",
+				"@types/mongoose": "^5.10.5",
 				"@types/mongoose-autopopulate": "^0.10.1",
 				"@types/mongoose-lean-virtuals": "^0.5.1",
 				"@types/multer": "^1.4.5",
@@ -60,7 +61,8 @@
 			}
 		},
 		"../util": {
-			"version": "1.3.55",
+			"name": "@fosscord/util",
+			"version": "1.0.0",
 			"hasInstallScript": true,
 			"license": "GPLV3",
 			"dependencies": {
diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts
index 06eeab39..a8bfe196 100644
--- a/api/src/middlewares/Authentication.ts
+++ b/api/src/middlewares/Authentication.ts
@@ -27,11 +27,12 @@ declare global {
 
 export async function Authentication(req: Request, res: Response, next: NextFunction) {
 	if (req.method === "OPTIONS") return res.sendStatus(204);
-	if (req.url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore
+	const url = req.url.replace(API_PREFIX, "");
+	if (url.startsWith("/invites") && req.method === "GET") return next(); // @ts-ignore
 	if (
 		NO_AUTHORIZATION_ROUTES.some((x) => {
-			if (typeof x === "string") return req.url.startsWith(x);
-			return x.test(req.url);
+			if (typeof x === "string") return url.startsWith(x);
+			return x.test(url);
 		})
 	)
 		return next();
diff --git a/api/src/routes/auth/login.ts b/api/src/routes/auth/login.ts
index a7247485..dc970e4c 100644
--- a/api/src/routes/auth/login.ts
+++ b/api/src/routes/auth/login.ts
@@ -4,7 +4,6 @@ import bcrypt from "bcrypt";
 import jwt from "jsonwebtoken";
 import { Config, UserModel } from "@fosscord/util";
 import { adjustEmail } from "./register";
-import RateLimit from "../../middlewares/RateLimit";
 
 const router: Router = Router();
 export default router;