diff options
author | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-05 19:52:42 +0200 |
---|---|---|
committer | Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> | 2021-10-05 19:52:42 +0200 |
commit | c3551d92543fd4ced618e2aac0be38f3ca9ee2df (patch) | |
tree | b7a8f2f948aa88d40d3b87f527b92458751398e2 /api/src | |
parent | :art: reformatted (diff) | |
download | server-c3551d92543fd4ced618e2aac0be38f3ca9ee2df.tar.xz |
:bug: fix user projection
Diffstat (limited to 'api/src')
-rw-r--r-- | api/src/routes/auth/register.ts | 4 | ||||
-rw-r--r-- | api/src/routes/users/@me/delete.ts | 2 | ||||
-rw-r--r-- | api/src/routes/users/@me/disable.ts | 2 | ||||
-rw-r--r-- | api/src/routes/users/@me/relationships.ts | 6 |
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) => { |