summary refs log tree commit diff
path: root/api/src/routes/users/@me
diff options
context:
space:
mode:
Diffstat (limited to 'api/src/routes/users/@me')
-rw-r--r--api/src/routes/users/@me/delete.ts11
-rw-r--r--api/src/routes/users/@me/guilds.ts4
-rw-r--r--api/src/routes/users/@me/profile.ts27
3 files changed, 8 insertions, 34 deletions
diff --git a/api/src/routes/users/@me/delete.ts b/api/src/routes/users/@me/delete.ts
index 6bfe0b93..e3b54607 100644
--- a/api/src/routes/users/@me/delete.ts
+++ b/api/src/routes/users/@me/delete.ts
@@ -1,6 +1,7 @@
 import { Router, Request, Response } from "express";
 import { Guild, Member, User } from "@fosscord/util";
 import bcrypt from "bcrypt";
+import { HTTPError } from "lambert-server";
 const router = Router();
 
 router.post("/", async (req: Request, res: Response) => {
@@ -9,16 +10,16 @@ router.post("/", async (req: Request, res: Response) => {
 
 	if (user.data.hash) {
 		// guest accounts can delete accounts without password
-		correctpass = await bcrypt.compare(req.body.password, user.data.hash); //Not sure if user typed right password :/
+		correctpass = await bcrypt.compare(req.body.password, user.data.hash);
+		if (!correctpass) {
+			throw new HTTPError(req.t("auth:login.INVALID_PASSWORD"));
+		}
 	}
 
 	// TODO: decrement guild member count
 
 	if (correctpass) {
-		await Promise.all([
-			User.delete({ id: req.user_id }), //Yeetus user deletus
-			Member.delete({ id: req.user_id })
-		]);
+		await Promise.all([User.delete({ id: req.user_id }), Member.delete({ user_id: req.user_id })]);
 
 		res.sendStatus(204);
 	} else {
diff --git a/api/src/routes/users/@me/guilds.ts b/api/src/routes/users/@me/guilds.ts
index fb88281b..1edb0eb1 100644
--- a/api/src/routes/users/@me/guilds.ts
+++ b/api/src/routes/users/@me/guilds.ts
@@ -6,7 +6,7 @@ import { In } from "typeorm";
 const router: Router = Router();
 
 router.get("/", async (req: Request, res: Response) => {
-	const members = await Member.find({ relations: ["guild"], where: { id: req.user_id } });
+	const members = await Member.find({ relations: ["guild"], where: { user_id: req.user_id } });
 
 	res.json(members.map((x) => x.guild));
 });
@@ -20,7 +20,7 @@ router.delete("/:id", async (req: Request, res: Response) => {
 	if (guild.owner_id === req.user_id) throw new HTTPError("You can't leave your own guild", 400);
 
 	await Promise.all([
-		Member.delete({ id: req.user_id, guild_id: guild_id }),
+		Member.delete({ user_id: req.user_id, guild_id: guild_id }),
 		emitEvent({
 			event: "GUILD_DELETE",
 			data: {
diff --git a/api/src/routes/users/@me/profile.ts b/api/src/routes/users/@me/profile.ts
deleted file mode 100644
index 5ba03c68..00000000
--- a/api/src/routes/users/@me/profile.ts
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Router, Request, Response } from "express";
-import { User } from "../../../../../util/dist";
-
-const router: Router = Router();
-
-router.get("/", async (req: Request, res: Response) => {
-	const user = await User.getPublicUser(req.user_id, { relations: ["connected_accounts"] });
-
-	res.json({
-		connected_accounts: user.connected_accounts,
-		premium_guild_since: null, // TODO
-		premium_since: null, // TODO
-		user: {
-			username: user.username,
-			discriminator: user.discriminator,
-			id: user.id,
-			public_flags: user.public_flags,
-			avatar: user.avatar,
-			accent_color: user.accent_color,
-			banner: user.banner,
-			bio: user.bio,
-			bot: user.bot
-		}
-	});
-});
-
-export default router;