summary refs log tree commit diff
path: root/api/src/routes/users/@me
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-06 18:25:30 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2022-08-09 23:28:27 +0200
commitcba3844c6f7a6b26c93d8061da0ca7fe6b291e92 (patch)
tree515a4000f4d26ab1999644b9dd6a057e03041bcf /api/src/routes/users/@me
parentmigrate to DataSource (diff)
downloadserver-ts-cba3844c6f7a6b26c93d8061da0ca7fe6b291e92.tar.xz
Resolve changes undone by rebasing from master
Diffstat (limited to 'api/src/routes/users/@me')
-rw-r--r--api/src/routes/users/@me/mfa/codes.ts12
-rw-r--r--api/src/routes/users/@me/mfa/totp/disable.ts4
-rw-r--r--api/src/routes/users/@me/notes.ts2
-rw-r--r--api/src/routes/users/@me/relationships.ts15
-rw-r--r--api/src/routes/users/@me/settings.ts2
5 files changed, 19 insertions, 16 deletions
diff --git a/api/src/routes/users/@me/mfa/codes.ts b/api/src/routes/users/@me/mfa/codes.ts

index 6ddf32f0..75e3e964 100644 --- a/api/src/routes/users/@me/mfa/codes.ts +++ b/api/src/routes/users/@me/mfa/codes.ts
@@ -15,7 +15,7 @@ export interface MfaCodesSchema { router.post("/", route({ body: "MfaCodesSchema" }), async (req: Request, res: Response) => { const { password, regenerate } = req.body as MfaCodesSchema; - const user = await User.findOneOrFail({ id: req.user_id }, { select: ["data"] }); + const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["data"] }); if (!await bcrypt.compare(password, user.data.hash || "")) { throw FieldErrors({ password: { message: req.t("auth:login.INVALID_PASSWORD"), code: "INVALID_PASSWORD" } }); @@ -33,10 +33,12 @@ router.post("/", route({ body: "MfaCodesSchema" }), async (req: Request, res: Re } else { codes = await BackupCode.find({ - user: { - id: req.user_id, - }, - expired: false, + where: { + user: { + id: req.user_id, + }, + expired: false + } }); } diff --git a/api/src/routes/users/@me/mfa/totp/disable.ts b/api/src/routes/users/@me/mfa/totp/disable.ts
index 5e039ea3..2d385fda 100644 --- a/api/src/routes/users/@me/mfa/totp/disable.ts +++ b/api/src/routes/users/@me/mfa/totp/disable.ts
@@ -13,9 +13,9 @@ export interface TotpDisableSchema { router.post("/", route({ body: "TotpDisableSchema" }), async (req: Request, res: Response) => { const body = req.body as TotpDisableSchema; - const user = await User.findOneOrFail({ id: req.user_id }, { select: ["totp_secret"] }); + const user = await User.findOneOrFail({ where: { id: req.user_id }, select: ["totp_secret"] }); - const backup = await BackupCode.findOne({ code: body.code }); + const backup = await BackupCode.findOne({ where: { code: body.code } }); if (!backup) { const ret = verifyToken(user.totp_secret!, body.code); if (!ret || ret.delta != 0) diff --git a/api/src/routes/users/@me/notes.ts b/api/src/routes/users/@me/notes.ts
index 3c503942..f938f088 100644 --- a/api/src/routes/users/@me/notes.ts +++ b/api/src/routes/users/@me/notes.ts
@@ -29,7 +29,7 @@ router.put("/:id", route({}), async (req: Request, res: Response) => { if (note && note.length) { // upsert a note - if (await Note.findOne({ owner: { id: owner.id }, target: { id: target.id } })) { + if (await Note.findOne({ where: { owner: { id: owner.id }, target: { id: target.id } } })) { Note.update( { owner: { id: owner.id }, target: { id: target.id } }, { owner, target, content: note } diff --git a/api/src/routes/users/@me/relationships.ts b/api/src/routes/users/@me/relationships.ts
index b2e39d52..0509b0ac 100644 --- a/api/src/routes/users/@me/relationships.ts +++ b/api/src/routes/users/@me/relationships.ts
@@ -45,7 +45,7 @@ router.put("/:id", route({ body: "RelationshipPutSchema" }), async (req: Request return await updateRelationship( req, res, - await User.findOneOrFail({ id: req.params.id }, { relations: ["relationships", "relationships.to"], select: userProjection }), + await User.findOneOrFail({ where: { id: req.params.id }, relations: ["relationships", "relationships.to"], select: userProjection }), req.body.type ?? RelationshipType.friends ); }); @@ -75,8 +75,8 @@ router.delete("/:id", route({}), async (req: Request, res: Response) => { const { id } = req.params; if (id === req.user_id) throw new HTTPError("You can't remove yourself as a friend"); - const user = await User.findOneOrFail({ id: req.user_id }, { select: userProjection, relations: ["relationships"] }); - const friend = await User.findOneOrFail({ id: id }, { select: userProjection, relations: ["relationships"] }); + const user = await User.findOneOrFail({ where: { id: req.user_id }, select: userProjection, relations: ["relationships"] }); + const friend = await User.findOneOrFail({ where: { id: id }, select: userProjection, relations: ["relationships"] }); const relationship = user.relationships.find((x) => x.to_id === id); const friendRequest = friend.relationships.find((x) => x.to_id === req.user_id); @@ -124,10 +124,11 @@ async function updateRelationship(req: Request, res: Response, friend: User, typ const id = friend.id; if (id === req.user_id) throw new HTTPError("You can't add yourself as a friend"); - const user = await User.findOneOrFail( - { id: req.user_id }, - { relations: ["relationships", "relationships.to"], select: userProjection } - ); + const user = await User.findOneOrFail({ + where: { id: req.user_id }, + relations: ["relationships", "relationships.to"], + select: userProjection + }); let relationship = user.relationships.find((x) => x.to_id === id); const friendRequest = friend.relationships.find((x) => x.to_id === req.user_id); diff --git a/api/src/routes/users/@me/settings.ts b/api/src/routes/users/@me/settings.ts
index b22b72fb..70f8a218 100644 --- a/api/src/routes/users/@me/settings.ts +++ b/api/src/routes/users/@me/settings.ts
@@ -10,7 +10,7 @@ router.patch("/", route({ body: "UserSettingsSchema" }), async (req: Request, re const body = req.body as UserSettings; if (body.locale === "en") body.locale = "en-US"; // fix discord client crash on unkown locale - const user = await User.findOneOrFail({ id: req.user_id, bot: false }); + const user = await User.findOneOrFail({ where: { id: req.user_id, bot: false } }); user.settings = { ...user.settings, ...body }; await user.save();