From 210362ab5bfab2a90a11094cfe8b7d5eac803442 Mon Sep 17 00:00:00 2001 From: kakkokari-gtyih <67428053+kakkokari-gtyih@users.noreply.github.com> Date: Sun, 22 Dec 2024 20:37:30 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=90=8C=E4=B8=80=E3=81=AE=E3=83=A1?= =?UTF-8?q?=E3=83=BC=E3=83=AB=E3=82=A2=E3=83=89=E3=83=AC=E3=82=B9=E3=81=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=82=8B?= =?UTF-8?q?=E3=82=A2=E3=82=AB=E3=82=A6=E3=83=B3=E3=83=88=E3=81=AF=E3=83=A1?= =?UTF-8?q?=E3=82=A2=E3=83=89=E3=83=AD=E3=82=B0=E3=82=A4=E3=83=B3=E3=81=A7?= =?UTF-8?q?=E3=81=8D=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/src/server/api/SigninApiService.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index 00f5bf2e79..5e8651ccce 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -110,7 +110,7 @@ export class SigninApiService { } // Fetch user - const profile = await this.userProfilesRepository.findOne({ + const profiles = await this.userProfilesRepository.find({ relations: ['user'], where: username.includes('@') ? { email: username, @@ -124,7 +124,22 @@ export class SigninApiService { host: IsNull(), }, }, + //同一のメールアドレスを使用しているアカウントが他にないかどうかを確認するために最大2件取得する + take: 2, + order: { + userId: 1, + }, }); + + if (profiles.length !== 1) { + // v12.96.0以前では同一のメールを複数のアカウントで使える。アカウントが複数見つかった場合・一つも見つからなかった場合は + // アカウントが見つからなかったときと同一のエラーを返す + return error(404, { + id: '6cc579cc-885d-43d8-95c2-b8c7fc963280', + }); + } + + const profile = profiles[0]; const user = (profile?.user as MiLocalUser) ?? null; if (user == null || profile == null) {