summary refs log tree commit diff
path: root/src/api/routes
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2026-07-20 12:44:56 +0200
committerRory& <root@rory.gay>2026-07-20 12:44:56 +0200
commit6494a14e8a4ff09700fa06e3928ccc030019ddeb (patch)
tree0a9eebe754ef377591596180f6176aa2b5889769 /src/api/routes
parentFix bot token reset (diff)
downloadserver-ts-6494a14e8a4ff09700fa06e3928ccc030019ddeb.tar.xz
Join bot on app
Diffstat (limited to 'src/api/routes')
-rw-r--r--src/api/routes/applications/#application_id/bot/index.ts10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/api/routes/applications/#application_id/bot/index.ts b/src/api/routes/applications/#application_id/bot/index.ts

index 27b6b9c1..d4ef6096 100644 --- a/src/api/routes/applications/#application_id/bot/index.ts +++ b/src/api/routes/applications/#application_id/bot/index.ts
@@ -67,19 +67,19 @@ router.post( }, }), async (req: Request, res: Response) => { - const app = await Application.findOneOrFail({ where: { id: req.params.application_id as string } }); - const bot = await User.findOneOrFail({ where: { id: req.params.application_id as string } }); + const app = await Application.findOneOrFail({ where: { id: req.params.application_id as string }, relations: { bot: true } }); const owner = await User.findOneOrFail({ where: { id: app.owner_id }, select: { id: true, totp_secret: true } }); + if (!app.bot) throw DiscordApiErrors.OAUTH2_APPLICATION_BOT_ABSENT; if (owner.id != req.user_id) throw DiscordApiErrors.ACTION_NOT_AUTHORIZED_ON_APPLICATION; if (owner.totp_secret && (!req.body.code || verifyToken(owner.totp_secret, req.body.code))) throw new HTTPError(req.t("auth:login.INVALID_TOTP_CODE"), 60008); - bot.data = { hash: undefined, valid_tokens_since: new Date() }; + app.bot.data = { hash: undefined, valid_tokens_since: new Date() }; - await bot.save(); + await app.bot.save(); - const token = await generateToken(bot.id); + const token = await generateToken(app.bot.id); res.json({ token }).status(200); },