From fa45456b7e01bb01c5bea6713bd3e551085f2d37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Rialland?= Date: Thu, 6 Oct 2022 17:34:51 +0200 Subject: [PATCH] Replace /run-all by a query param in /connect --- standup-mattermost-bot/source/server.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/standup-mattermost-bot/source/server.ts b/standup-mattermost-bot/source/server.ts index 287ab17f6..ca62c098c 100644 --- a/standup-mattermost-bot/source/server.ts +++ b/standup-mattermost-bot/source/server.ts @@ -25,20 +25,21 @@ const router = new Router() app.use(cors()) router.get('/connect', (ctx) => { + const { state = '' } = ctx.query const url = `${serverUrl}/oauth/authorize?` + [ `client_id=${clientId}`, `redirect_uri=${redirectUri}`, `response_type=code`, - `state=`, + `state=${state?.toString()}`, ].join('&') ctx.redirect(url) }) router.get('/oauth', async (ctx) => { - const { code, error } = ctx.query + const { code, error, state } = ctx.query if (error) { ctx.status = 400 @@ -64,6 +65,10 @@ router.get('/oauth', async (ctx) => { await mongo.saveOAuth(snakeToCamelCaseKeys(body)) + if (state === 'run-all') { + await bree.run() + } + ctx.status = 200 } catch (err) { // eslint-disable-next-line no-console @@ -73,11 +78,6 @@ router.get('/oauth', async (ctx) => { } }) -router.get('/run-all', async (ctx) => { - await bree.run() - ctx.status = 200 -}) - app.use(router.routes()) app.use(router.allowedMethods())