From c5008452c1c6a6d58ece96e420c7276b54e65b4f Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Wed, 8 Nov 2023 22:18:28 +0100 Subject: [PATCH] fix: oauth/authorize not working --- packages/backend/src/server/ServerService.ts | 11 +++++++++++ .../src/server/oauth/OAuth2ProviderService.ts | 19 ------------------- 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/packages/backend/src/server/ServerService.ts b/packages/backend/src/server/ServerService.ts index 16bcfc7459..aaed447253 100644 --- a/packages/backend/src/server/ServerService.ts +++ b/packages/backend/src/server/ServerService.ts @@ -186,6 +186,17 @@ export class ServerService implements OnApplicationShutdown { } }); + fastify.get('/oauth/authorize', async (request, reply) => { + const query: any = request.query; + let param = "mastodon=true"; + if (query.state) param += `&state=${query.state}`; + if (query.redirect_uri) param += `&redirect_uri=${query.redirect_uri}`; + const client = query.client_id ? query.client_id : ""; + reply.redirect( + `${Buffer.from(client.toString(), 'base64').toString()}?${param}`, + ); + }); + fastify.get<{ Params: { code: string } }>('/verify-email/:code', async (request, reply) => { const profile = await this.userProfilesRepository.findOneBy({ emailVerifyCode: request.params.code, diff --git a/packages/backend/src/server/oauth/OAuth2ProviderService.ts b/packages/backend/src/server/oauth/OAuth2ProviderService.ts index 6d9cac2a17..8cd49d3487 100644 --- a/packages/backend/src/server/oauth/OAuth2ProviderService.ts +++ b/packages/backend/src/server/oauth/OAuth2ProviderService.ts @@ -67,25 +67,6 @@ export class OAuth2ProviderService { payload.on('error', done); }); - fastify.get('/oauth/authorize', async (request, reply) => { - const query: any = request.query; - let param = "mastodon=true"; - if (query.state) param += `&state=${query.state}`; - if (query.redirect_uri) param += `&redirect_uri=${query.redirect_uri}`; - const client = query.client_id ? query.client_id : ""; - reply.redirect( - `${Buffer.from(client.toString(), 'base64').toString()}?${param}`, - ); - }); - - fastify.post('/oauth/decision', async (request, reply) => { - const body: any = request.body; - if (body.cancel) { - reply.send({ user: body.login_token, allow: false }); - } - reply.send({ user: body.login_token, allow: true }); - }); - fastify.post('/oauth/token', async (request, reply) => { const body: any = request.body || request.query; if (body.grant_type === "client_credentials") {