summary refs log tree commit diff
path: root/src/api/routes/applications/#id/index.ts
diff options
context:
space:
mode:
authorEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
committerEmma [it/its]@Rory& <root@rory.gay>2023-12-11 01:12:54 +0100
commit0a8ceb9e6349284e75545a01ffad608b020f78e2 (patch)
tree17a9163f963eddabf9168b0b630096b2f7535b64 /src/api/routes/applications/#id/index.ts
parentPrettier: use editorconfig (diff)
downloadserver-0a8ceb9e6349284e75545a01ffad608b020f78e2.tar.xz
Actually run prettier dev/emma-refactors
Diffstat (limited to 'src/api/routes/applications/#id/index.ts')
-rw-r--r--src/api/routes/applications/#id/index.ts35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/api/routes/applications/#id/index.ts b/src/api/routes/applications/#id/index.ts
index c372869a..9b8c2d46 100644
--- a/src/api/routes/applications/#id/index.ts
+++ b/src/api/routes/applications/#id/index.ts
@@ -17,11 +17,7 @@
 */
 
 import { route } from "@spacebar/api";
-import {
-	Application,
-	ApplicationModifySchema,
-	DiscordApiErrors,
-} from "@spacebar/util";
+import { Application, ApplicationModifySchema, DiscordApiErrors } from "@spacebar/util";
 import { Request, Response, Router } from "express";
 import { HTTPError } from "lambert-server";
 import { verifyToken } from "node-2fa";
@@ -45,11 +41,10 @@ router.get(
 			where: { id: req.params.id },
 			relations: ["owner", "bot"],
 		});
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
 		return res.json(app);
-	},
+	}
 );
 
 router.patch(
@@ -73,14 +68,9 @@ router.patch(
 			relations: ["owner", "bot"],
 		});
 
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
 
-		if (
-			app.owner.totp_secret &&
-			(!req.body.code ||
-				verifyToken(app.owner.totp_secret, req.body.code))
-		)
+		if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		if (app.bot) {
@@ -93,7 +83,7 @@ router.patch(
 		await app.save();
 
 		return res.json(app);
-	},
+	}
 );
 
 router.post(
@@ -111,20 +101,15 @@ router.post(
 			where: { id: req.params.id },
 			relations: ["bot", "owner"],
 		});
-		if (app.owner.id != req.user_id)
-			throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
-
-		if (
-			app.owner.totp_secret &&
-			(!req.body.code ||
-				verifyToken(app.owner.totp_secret, req.body.code))
-		)
+		if (app.owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION;
+
+		if (app.owner.totp_secret && (!req.body.code || verifyToken(app.owner.totp_secret, req.body.code)))
 			throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008);
 
 		await Application.delete({ id: app.id });
 
 		res.send().status(200);
-	},
+	}
 );
 
 export default router;