summary refs log tree commit diff
path: root/api/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-05 19:52:42 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-05 19:52:42 +0200
commitc3551d92543fd4ced618e2aac0be38f3ca9ee2df (patch)
treeb7a8f2f948aa88d40d3b87f527b92458751398e2 /api/src
parent:art: reformatted (diff)
downloadserver-c3551d92543fd4ced618e2aac0be38f3ca9ee2df.tar.xz
:bug: fix user projection
Diffstat (limited to 'api/src')
-rw-r--r--api/src/routes/auth/register.ts4
-rw-r--r--api/src/routes/users/@me/delete.ts2
-rw-r--r--api/src/routes/users/@me/disable.ts2
-rw-r--r--api/src/routes/users/@me/relationships.ts6
4 files changed, 9 insertions, 5 deletions
diff --git a/api/src/routes/auth/register.ts b/api/src/routes/auth/register.ts
index c016c949..9f3b46f1 100644
--- a/api/src/routes/auth/register.ts
+++ b/api/src/routes/auth/register.ts
@@ -79,7 +79,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
 
 	if (!register.allowMultipleAccounts) {
 		// TODO: check if fingerprint was eligible generated
-		const exists = await User.findOne({ where: { fingerprints: body.fingerprint } });
+		const exists = await User.findOne({ where: { fingerprints: body.fingerprint }, select: ["id"] });
 
 		if (exists) {
 			throw FieldErrors({
@@ -109,7 +109,7 @@ router.post("/", route({ body: "RegisterSchema" }), async (req: Request, res: Re
 		}
 
 		// check if there is already an account with this email
-		const exists = await User.findOneOrFail({ email: email }).catch((e) => {});
+		const exists = await User.findOne({ email: email });
 
 		if (exists) {
 			throw FieldErrors({
diff --git a/api/src/routes/users/@me/delete.ts b/api/src/routes/users/@me/delete.ts
index 39ceefd9..c24c3f1e 100644
--- a/api/src/routes/users/@me/delete.ts
+++ b/api/src/routes/users/@me/delete.ts
@@ -7,7 +7,7 @@ import { HTTPError } from "lambert-server";
 const router = Router();
 
 router.post("/", route({}), async (req: Request, res: Response) => {
-	const user = await User.findOneOrFail({ id: req.user_id }); //User object
+	const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); //User object
 	let correctpass = true;
 
 	if (user.data.hash) {
diff --git a/api/src/routes/users/@me/disable.ts b/api/src/routes/users/@me/disable.ts
index 259ced96..4aff3774 100644
--- a/api/src/routes/users/@me/disable.ts
+++ b/api/src/routes/users/@me/disable.ts
@@ -6,7 +6,7 @@ import bcrypt from "bcrypt";
 const router = Router();
 
 router.post("/", route({}), async (req: Request, res: Response) => {
-	const user = await User.findOneOrFail({ id: req.user_id }); //User object
+	const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); //User object
 	let correctpass = true;
 
 	if (user.data.hash) {
diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index 567c734e..0c13cdba 100644
--- a/api/src/routes/users/@me/relationships.ts
+++ b/api/src/routes/users/@me/relationships.ts
@@ -18,7 +18,11 @@ const router = Router();
 const userProjection: (keyof User)[] = ["relationships", ...PublicUserProjection];
 
 router.get("/", route({}), async (req: Request, res: Response) => {
-	const user = await User.findOneOrFail({ where: { id: req.user_id }, relations: ["relationships", "relationships.to"] });
+	const user = await User.findOneOrFail({
+		where: { id: req.user_id },
+		relations: ["relationships", "relationships.to"],
+		select: ["relationships"]
+	});
 
 	//TODO DTO
 	const related_users = user.relationships.map((r) => {