From 8db7bd1e3f1b0807859012196d3a34020a68ecc2 Mon Sep 17 00:00:00 2001 From: Asa <26807394+a01sa01to@users.noreply.github.com> Date: Sat, 9 Nov 2024 12:14:42 +0900 Subject: [PATCH] =?UTF-8?q?perf=20=E7=84=A1=E9=A7=84=E3=81=AA=20join=20?= =?UTF-8?q?=E3=82=92=E5=89=8A=E6=B8=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/api/oauth/callback.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/webapp/api/oauth/callback.ts b/webapp/api/oauth/callback.ts index 4cb5935..81e4406 100644 --- a/webapp/api/oauth/callback.ts +++ b/webapp/api/oauth/callback.ts @@ -105,19 +105,15 @@ app.post( // scope 取得 const requestedScopes = new Set(scope ? scope.split(' ') : []) const scopes = ( - await c.var.dbClient.query.oauthClient.findMany({ - where: (oauthClient, { eq }) => eq(oauthClient.id, client_id), + await c.var.dbClient.query.oauthClientScope.findMany({ + where: (oauthClientScope, { eq }) => + eq(oauthClientScope.client_id, client_id), with: { - scopes: { - with: { - scope: true, - }, - }, + scope: true, }, }) ) - .map(client => client.scopes.map(scope => scope.scope)) - .flat() + .map(clientScope => clientScope.scope) .filter(data => { // scope リクエストしてない場合は requestedScopes = [] なので、全部 true として付与 if (requestedScopes.size === 0) return true