From 8abe8aecee823e9c2a5de36a797489968fef4611 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=82=8F=E3=82=8F=E3=82=8F=E3=81=A8=E3=83=BC?= =?UTF-8?q?=E3=81=AB=E3=82=85?= <17376330+u1-liquid@users.noreply.github.com> Date: Wed, 25 Dec 2024 09:43:25 +0900 Subject: [PATCH] =?UTF-8?q?fix(sign-in):=20=E3=83=AD=E3=82=B0=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E5=A4=B1=E6=95=97=E6=99=82=E3=81=AE=E3=82=A8=E3=83=A9?= =?UTF-8?q?=E3=83=BC=E3=82=B3=E3=83=BC=E3=83=89=E3=81=AE=E7=B5=B1=E4=B8=80?= =?UTF-8?q?=20(MisskeyIO#843)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locales/ar-SA.yml | 1 + locales/bn-BD.yml | 1 + locales/ca-ES.yml | 1 + locales/cs-CZ.yml | 1 + locales/de-DE.yml | 1 + locales/en-US.yml | 1 + locales/es-ES.yml | 1 + locales/fr-FR.yml | 1 + locales/id-ID.yml | 1 + locales/index.d.ts | 4 ++ locales/it-IT.yml | 1 + locales/ja-JP.yml | 1 + locales/ja-KS.yml | 1 + locales/ko-KR.yml | 1 + locales/pl-PL.yml | 1 + locales/pt-PT.yml | 1 + locales/ru-RU.yml | 1 + locales/sk-SK.yml | 1 + locales/sv-SE.yml | 1 + locales/th-TH.yml | 1 + locales/uk-UA.yml | 1 + locales/vi-VN.yml | 1 + locales/zh-CN.yml | 1 + locales/zh-TW.yml | 1 + .../src/server/api/SigninApiService.ts | 49 ++++++++++--------- packages/frontend/src/components/MkSignin.vue | 2 +- 26 files changed, 53 insertions(+), 25 deletions(-) diff --git a/locales/ar-SA.yml b/locales/ar-SA.yml index 88707fe11..7e3047050 100644 --- a/locales/ar-SA.yml +++ b/locales/ar-SA.yml @@ -822,6 +822,7 @@ unmuteThread: "ارفع الكتم عن النقاش" continueThread: "اعرض بقية النقاش" deleteAccountConfirm: "سيحذف حسابك نهائيًا، أتريد المتابعة؟" incorrectPassword: "كلمة السر خاطئة." +authenticationFailed: "فشل التوثيق" voteConfirm: "متيقِّن من تصويتك لـ {choice}؟" hide: "إخفاء" welcomeBackWithName: "مرحبًا بك مجددًا {name}" diff --git a/locales/bn-BD.yml b/locales/bn-BD.yml index dc5d315ae..79fe3a63b 100644 --- a/locales/bn-BD.yml +++ b/locales/bn-BD.yml @@ -815,6 +815,7 @@ unmuteThread: "থ্রেড আনমিউট করুন" continueThread: "আরো থ্রেড দেখুন" deleteAccountConfirm: "আপনার অ্যাকাউন্ট মুছে ফেলা হবে। ঠিক আছে?" incorrectPassword: "আপনার দেওয়া পাসওয়ার্ডটি ভুল।" +authenticationFailed: "প্রমাণীকরণ ব্যর্থ হয়েছে।" voteConfirm: "\"{choice}\" এ ভোট দিতে চান?" hide: "লুকান" useDrawerReactionPickerForMobile: "মোবাইলে রিঅ্যাকশন পিকারকে ড্রয়ারে প্রদর্শন করুন" diff --git a/locales/ca-ES.yml b/locales/ca-ES.yml index c00696340..447c44494 100644 --- a/locales/ca-ES.yml +++ b/locales/ca-ES.yml @@ -896,6 +896,7 @@ followersVisibility: "Visibilitat dels seguidors" continueThread: "Veure la continuació del fil" deleteAccountConfirm: "Això eliminarà el teu compte irreversiblement. Procedir?" incorrectPassword: "Contrasenya incorrecta." +authenticationFailed: "Autenticació fallida." voteConfirm: "Confirma el teu vot \"{choice}\"" hide: "Amagar" useDrawerReactionPickerForMobile: "Mostrar el selector de reaccions com un calaix al mòbil " diff --git a/locales/cs-CZ.yml b/locales/cs-CZ.yml index cff533976..993e06fd9 100644 --- a/locales/cs-CZ.yml +++ b/locales/cs-CZ.yml @@ -859,6 +859,7 @@ unmuteThread: "Zrušit ztlumení vlákna" continueThread: "Zobrazit pokračování vlákna" deleteAccountConfirm: "Tohle nenávratně smaže váš účet, chcete pokračovat?" incorrectPassword: "Nesprávné heslo." +authenticationFailed: "Ověření selhalo." voteConfirm: "Potvrdit hlas pro \"{choice}\"?" hide: "Skrýt" useDrawerReactionPickerForMobile: "Zobrazit výběr reakcí jako šuplík na mobilním zařízení" diff --git a/locales/de-DE.yml b/locales/de-DE.yml index e83d0d40b..f2d0ad178 100644 --- a/locales/de-DE.yml +++ b/locales/de-DE.yml @@ -889,6 +889,7 @@ unmuteThread: "Threadstummschaltung aufheben" continueThread: "Weiteren Threadverlauf anzeigen" deleteAccountConfirm: "Dein Benutzerkonto wird unwiderruflich gelöscht. Trotzdem fortfahren?" incorrectPassword: "Falsches Passwort." +authenticationFailed: "Authentifizierung fehlgeschlagen." voteConfirm: "Wirklich für „{choice}“ abstimmen?" hide: "Inhalt verbergen" useDrawerReactionPickerForMobile: "Auf mobilen Geräten ausfahrbare Reaktionsauswahl anzeigen" diff --git a/locales/en-US.yml b/locales/en-US.yml index e83883d3c..6b8033b1e 100644 --- a/locales/en-US.yml +++ b/locales/en-US.yml @@ -919,6 +919,7 @@ continueThread: "View thread continuation" deleteAccountConfirm: "This will irreversibly delete your account. Proceed?" deleteAccountConfirmAndWarn: "This will irreversibly delete your account.\nPlease note that re-logging in after a deletion request will interrupt the deletion of your account.\nProceed?" incorrectPassword: "Incorrect password." +authenticationFailed: "Authentication failed." voteConfirm: "Confirm your vote for \"{choice}\"?" hide: "Hide" useDrawerReactionPickerForMobile: "Display reaction picker as drawer on mobile" diff --git a/locales/es-ES.yml b/locales/es-ES.yml index ffe6b239f..ca2202b76 100644 --- a/locales/es-ES.yml +++ b/locales/es-ES.yml @@ -896,6 +896,7 @@ followersVisibility: "Visibilidad de seguidores" continueThread: "Ver la continuación del hilo" deleteAccountConfirm: "La cuenta será borrada. ¿Está seguro?" incorrectPassword: "La contraseña es incorrecta" +authenticationFailed: "La autenticación falló" voteConfirm: "¿Confirma su voto a {choice}?" hide: "Ocultar" useDrawerReactionPickerForMobile: "Mostrar panel de reacciones en móviles" diff --git a/locales/fr-FR.yml b/locales/fr-FR.yml index 9fb852ca2..d20fc7682 100644 --- a/locales/fr-FR.yml +++ b/locales/fr-FR.yml @@ -896,6 +896,7 @@ followersVisibility: "Visibilité des abonnés" continueThread: "Afficher la suite du fil" deleteAccountConfirm: "Votre compte sera supprimé. Êtes vous certain ?" incorrectPassword: "Le mot de passe est incorrect." +authenticationFailed: "L'authentification a échoué." voteConfirm: "Confirmez-vous votre vote pour « {choice} » ?" hide: "Masquer" useDrawerReactionPickerForMobile: "Afficher le sélecteur de réactions en tant que panneau sur mobile" diff --git a/locales/id-ID.yml b/locales/id-ID.yml index dd67e2d5a..ac7128b51 100644 --- a/locales/id-ID.yml +++ b/locales/id-ID.yml @@ -896,6 +896,7 @@ followersVisibility: "Visibilitas pengikut" continueThread: "Lihat lanjutan thread" deleteAccountConfirm: "Akun akan dihapus. Apakah kamu yakin?" incorrectPassword: "Kata sandi salah." +authenticationFailed: "Autentikasi gagal." voteConfirm: "Konfirmasi suara kamu untuk ({choice})?" hide: "Sembunyikan" useDrawerReactionPickerForMobile: "Tampilkan bilah reaksi sebagai laci di ponsel" diff --git a/locales/index.d.ts b/locales/index.d.ts index 1bc040dde..045db3c84 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -3703,6 +3703,10 @@ export interface Locale extends ILocale { * パスワードが間違っています。 */ "incorrectPassword": string; + /** + * 認証に失敗しました。 + */ + "authenticationFailed": string; /** * 「{choice}」に投票しますか? */ diff --git a/locales/it-IT.yml b/locales/it-IT.yml index af0dc9d05..4590ec1a5 100644 --- a/locales/it-IT.yml +++ b/locales/it-IT.yml @@ -896,6 +896,7 @@ followersVisibility: "Visibilità dei profili che ti seguono" continueThread: "Altre conversazioni" deleteAccountConfirm: "Così verrà eliminato il profilo. Vuoi procedere?" incorrectPassword: "La password è errata." +authenticationFailed: "Autenticazione fallita" voteConfirm: "Votare per「{choice}」?" hide: "Nascondere" useDrawerReactionPickerForMobile: "Mostra sul drawer da dispositivo mobile" diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 514484dc5..7465bdbb0 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -921,6 +921,7 @@ continueThread: "さらにスレッドを見る" deleteAccountConfirm: "アカウントが削除されます。よろしいですか?" deleteAccountConfirmAndWarn: "アカウントが削除されます。\n削除リクエスト後に再ログインすると\nアカウントの削除が中断されてしまいますのでご注意ください。\nよろしいですか?" incorrectPassword: "パスワードが間違っています。" +authenticationFailed: "認証に失敗しました。" voteConfirm: "「{choice}」に投票しますか?" hide: "隠す" useDrawerReactionPickerForMobile: "モバイルデバイスのときドロワーで表示" diff --git a/locales/ja-KS.yml b/locales/ja-KS.yml index 121b12b1c..06bd3e27a 100644 --- a/locales/ja-KS.yml +++ b/locales/ja-KS.yml @@ -896,6 +896,7 @@ followersVisibility: "フォロワーの公開範囲" continueThread: "さらにスレッドを見るで" deleteAccountConfirm: "アカウントを消すで?ええんか?" incorrectPassword: "パスワードがちゃうわ。" +authenticationFailed: "認証失敗したで。" voteConfirm: "「{choice}」に投票するんか?" hide: "隠す" useDrawerReactionPickerForMobile: "ケータイとかのときドロワーで表示するで" diff --git a/locales/ko-KR.yml b/locales/ko-KR.yml index e65ddaea2..466d77d21 100644 --- a/locales/ko-KR.yml +++ b/locales/ko-KR.yml @@ -918,6 +918,7 @@ continueThread: "글타래 더 보기" deleteAccountConfirm: "계정이 삭제되고 되돌릴 수 없게 됩니다. 계속하시겠습니까?" deleteAccountConfirmAndWarn: "계정이 삭제됩니다.\n삭제 요청 후 다시 로그인하면 계정 삭제가 중단되어 버립니다.\n계속하시겠습니까?" incorrectPassword: "비밀번호가 올바르지 않습니다." +authenticationFailed: "인증에 실패했습니다." voteConfirm: "\"{choice}\"에 투표하시겠습니까?" hide: "숨기기" useDrawerReactionPickerForMobile: "모바일에서 드로어 메뉴로 표시" diff --git a/locales/pl-PL.yml b/locales/pl-PL.yml index 2183aa302..7dc38ac31 100644 --- a/locales/pl-PL.yml +++ b/locales/pl-PL.yml @@ -894,6 +894,7 @@ followersVisibility: "Widoczność obserwujących" continueThread: "Pokaż kontynuację wątku" deleteAccountConfirm: "Spowoduje to nieodwracalne usunięcie Twojego konta. Kontynuować?" incorrectPassword: "Nieprawidłowe hasło." +authenticationFailed: "Uwierzytelnienie nie powiodło się." voteConfirm: "Potwierdzić swój głos na \"{choice}\"?" hide: "Ukryj" useDrawerReactionPickerForMobile: "Wyświetlaj wybornik reakcji jako szufladę na urządzeniach mobilnych" diff --git a/locales/pt-PT.yml b/locales/pt-PT.yml index e00f5750d..2cd62f1f9 100644 --- a/locales/pt-PT.yml +++ b/locales/pt-PT.yml @@ -863,6 +863,7 @@ unmuteThread: "Desativar silêncio desta conversa" continueThread: "Ver mais desta conversa" deleteAccountConfirm: "Deseja realmente excluir a conta?" incorrectPassword: "Senha inválida." +authenticationFailed: "Falha na autenticação." voteConfirm: "Deseja confirmar o seu voto em \"{choice}\"?" hide: "Ocultar" useDrawerReactionPickerForMobile: "Mostrar em formato de gaveta" diff --git a/locales/ru-RU.yml b/locales/ru-RU.yml index 66e032f16..074a1ab95 100644 --- a/locales/ru-RU.yml +++ b/locales/ru-RU.yml @@ -881,6 +881,7 @@ unmuteThread: "Отменить сокрытие цепочки" continueThread: "Показать следующие ответы" deleteAccountConfirm: "Учётная запись будет безвозвратно удалена. Подтверждаете?" incorrectPassword: "Пароль неверен." +authenticationFailed: "Аутентификация не удалась." voteConfirm: "Отдать голос за «{choice}»?" hide: "Спрятать" useDrawerReactionPickerForMobile: "Выдвижная палитра на мобильном устройстве" diff --git a/locales/sk-SK.yml b/locales/sk-SK.yml index 0978701e5..dbfa4e2e4 100644 --- a/locales/sk-SK.yml +++ b/locales/sk-SK.yml @@ -826,6 +826,7 @@ unmuteThread: "Zrušiť stíšenie vlákna" continueThread: "Zobraziť pokračovanie vlákna" deleteAccountConfirm: "Toto nezvrátiteľne vymaže váš účet. Pokračovať?" incorrectPassword: "Nesprávne heslo." +authenticationFailed: "Overenie zlyhalo." voteConfirm: "Potvrdzujete svoj hlas za \"{choice}\"?" hide: "Skryť" useDrawerReactionPickerForMobile: "Zobraziť výber reakcií ako šuflík na mobile" diff --git a/locales/sv-SE.yml b/locales/sv-SE.yml index 62bc71a13..83c9278ab 100644 --- a/locales/sv-SE.yml +++ b/locales/sv-SE.yml @@ -466,6 +466,7 @@ squareAvatars: "Visa fyrkantiga profilbilder" sent: "Skicka" misskeyUpdated: "Misskey har uppdaterats!" incorrectPassword: "Fel lösenord." +authenticationFailed: "Autentisering misslyckades." welcomeBackWithName: "Välkommen tillbaka, {name}" clickToFinishEmailVerification: "Tryck på [{ok}] för att slutföra bekräftelsen på e-postadressen." searchByGoogle: "Sök" diff --git a/locales/th-TH.yml b/locales/th-TH.yml index 37d6169d0..0ecafb94e 100644 --- a/locales/th-TH.yml +++ b/locales/th-TH.yml @@ -896,6 +896,7 @@ followersVisibility: "การมองเห็นผู้ที่กำล continueThread: "ดูความต่อเนื่องเธรด" deleteAccountConfirm: "การดำเนินการนี้จะลบบัญชีของคุณอย่างถาวรเลยนะ แน่ใจหรอดำเนินการ?" incorrectPassword: "รหัสผ่านไม่ถูกต้อง" +authenticationFailed: "การตรวจสอบตัวตนล้มเหลว" voteConfirm: "ต้องการโหวต “{choice}” ใช่ไหม?" hide: "ซ่อน" useDrawerReactionPickerForMobile: "แสดง ตัวจิ้มรีแอคชั่น เป็นแบบลิ้นชัก เมื่อใช้บนมือถือ" diff --git a/locales/uk-UA.yml b/locales/uk-UA.yml index 0ce5dc120..02b6543cf 100644 --- a/locales/uk-UA.yml +++ b/locales/uk-UA.yml @@ -822,6 +822,7 @@ unmuteThread: "Скасувати глушіння" continueThread: "Показати продовження треду" deleteAccountConfirm: "Це незворотно видалить ваш акаунт. Продовжити?" incorrectPassword: "Неправильний пароль." +authenticationFailed: "Аутентифікація не вдалася." voteConfirm: "Підтверджуєте свій голос за \"{choice}\"?" hide: "Сховати" welcomeBackWithName: "З поверненням, {name}!" diff --git a/locales/vi-VN.yml b/locales/vi-VN.yml index d9c21d29a..870867893 100644 --- a/locales/vi-VN.yml +++ b/locales/vi-VN.yml @@ -876,6 +876,7 @@ followersVisibility: "Hiển thị người theo dõi" continueThread: "Tiếp tục xem chuỗi tút" deleteAccountConfirm: "Điều này sẽ khiến tài khoản bị xóa vĩnh viễn. Vẫn tiếp tục?" incorrectPassword: "Sai mật khẩu." +authenticationFailed: "Xác thực thất bại." voteConfirm: "Xác nhận bình chọn \"{choice}\"?" hide: "Ẩn" useDrawerReactionPickerForMobile: "Hiện bộ chọn biểu cảm dạng xổ ra trên điện thoại" diff --git a/locales/zh-CN.yml b/locales/zh-CN.yml index 1364ae375..515450758 100644 --- a/locales/zh-CN.yml +++ b/locales/zh-CN.yml @@ -899,6 +899,7 @@ followersVisibility: "关注者的公开范围" continueThread: "查看更多帖子" deleteAccountConfirm: "将要删除账户。是否确认?" incorrectPassword: "密码错误" +authenticationFailed: "认证失败" voteConfirm: "确定投给 “{choice}” ?" hide: "隐藏" useDrawerReactionPickerForMobile: "在移动设备上使用抽屉显示" diff --git a/locales/zh-TW.yml b/locales/zh-TW.yml index 7ad9ca909..a759f4320 100644 --- a/locales/zh-TW.yml +++ b/locales/zh-TW.yml @@ -896,6 +896,7 @@ followersVisibility: "追隨者的可見性" continueThread: "查看更多貼文" deleteAccountConfirm: "將要刪除帳戶。是否確定?" incorrectPassword: "密碼錯誤。" +authenticationFailed: "驗證失敗。" voteConfirm: "確定投給「{choice}」?" hide: "隱藏" useDrawerReactionPickerForMobile: "在移動設備上使用抽屜顯示" diff --git a/packages/backend/src/server/api/SigninApiService.ts b/packages/backend/src/server/api/SigninApiService.ts index ec1ec567d..a56a2d85b 100644 --- a/packages/backend/src/server/api/SigninApiService.ts +++ b/packages/backend/src/server/api/SigninApiService.ts @@ -122,10 +122,12 @@ export class SigninApiService { return; } + const loginWithEmail = username.includes('@'); + // Fetch user const profile = await this.userProfilesRepository.findOne({ relations: ['user'], - where: username.includes('@') ? { + where: loginWithEmail ? { email: username, emailVerified: true, user: { @@ -143,21 +145,21 @@ export class SigninApiService { if (!user || !profile) { logger.error('No such user.'); return error(403, { - id: '932c904e-9460-45b7-9ce6-7ed33be7eb2c', + id: loginWithEmail ? '932c904e-9460-45b7-9ce6-7ed33be7eb2c' : '6cc579cc-885d-43d8-95c2-b8c7fc963280', }); } if (user.isDeleted && user.isSuspended) { logger.error('No such user. (logical deletion)'); return error(403, { - id: '932c904e-9460-45b7-9ce6-7ed33be7eb2c', + id: loginWithEmail ? '932c904e-9460-45b7-9ce6-7ed33be7eb2c' : '6cc579cc-885d-43d8-95c2-b8c7fc963280', }); } if (user.isSuspended) { logger.error('User is suspended.'); return error(403, { - id: 'e03a5f46-d309-4865-9b69-56282d94e1eb', + id: loginWithEmail ? '932c904e-9460-45b7-9ce6-7ed33be7eb2c' : 'e03a5f46-d309-4865-9b69-56282d94e1eb', }); } @@ -180,27 +182,26 @@ export class SigninApiService { if (!profile.twoFactorEnabled) { if (process.env.NODE_ENV !== 'test') { const meta = await this.metaService.fetch(); - if (meta.enableHcaptcha && meta.hcaptchaSecretKey) { - await this.captchaService.verifyHcaptcha(meta.hcaptchaSecretKey, body['hcaptcha-response']).catch(err => { - throw new FastifyReplyError(400, err); - }); - } + try { + if (meta.enableHcaptcha && meta.hcaptchaSecretKey) { + await this.captchaService.verifyHcaptcha(meta.hcaptchaSecretKey, body['hcaptcha-response']); + } - if (meta.enableMcaptcha && meta.mcaptchaSecretKey && meta.mcaptchaSitekey && meta.mcaptchaInstanceUrl) { - await this.captchaService.verifyMcaptcha(meta.mcaptchaSecretKey, meta.mcaptchaSitekey, meta.mcaptchaInstanceUrl, body['m-captcha-response']).catch(err => { - throw new FastifyReplyError(400, err); - }); - } + if (meta.enableMcaptcha && meta.mcaptchaSecretKey && meta.mcaptchaSitekey && meta.mcaptchaInstanceUrl) { + await this.captchaService.verifyMcaptcha(meta.mcaptchaSecretKey, meta.mcaptchaSitekey, meta.mcaptchaInstanceUrl, body['m-captcha-response']); + } - if (meta.enableRecaptcha && meta.recaptchaSecretKey) { - await this.captchaService.verifyRecaptcha(meta.recaptchaSecretKey, body['g-recaptcha-response']).catch(err => { - throw new FastifyReplyError(400, err); - }); - } + if (meta.enableRecaptcha && meta.recaptchaSecretKey) { + await this.captchaService.verifyRecaptcha(meta.recaptchaSecretKey, body['g-recaptcha-response']); + } - if (meta.enableTurnstile && meta.turnstileSecretKey) { - await this.captchaService.verifyTurnstile(meta.turnstileSecretKey, body['turnstile-response']).catch(err => { - throw new FastifyReplyError(400, err); + if (meta.enableTurnstile && meta.turnstileSecretKey) { + await this.captchaService.verifyTurnstile(meta.turnstileSecretKey, body['turnstile-response']); + } + } catch (err) { + logger.error(`Invalid request: captcha verification failed: ${err}`); + return await fail(403, { + id: '932c904e-9460-45b7-9ce6-7ed33be7eb2c', }); } } @@ -229,7 +230,7 @@ export class SigninApiService { } catch (e) { logger.error('Invalid request: Unable to authenticate with two-factor token.'); return await fail(403, { - id: 'cdf1235b-ac71-46d4-a3a6-84ccce48df6f', + id: '932c904e-9460-45b7-9ce6-7ed33be7eb2c', }); } @@ -251,7 +252,7 @@ export class SigninApiService { } else { logger.error('Invalid request: Unable to authenticate with WebAuthn credential.'); return await fail(403, { - id: '93b86c4b-72f9-40eb-9815-798928603d1e', + id: '932c904e-9460-45b7-9ce6-7ed33be7eb2c', }); } } else { diff --git a/packages/frontend/src/components/MkSignin.vue b/packages/frontend/src/components/MkSignin.vue index feb1f8acf..fea4213ac 100644 --- a/packages/frontend/src/components/MkSignin.vue +++ b/packages/frontend/src/components/MkSignin.vue @@ -241,7 +241,7 @@ function loginFailed(err: any): void { os.alert({ type: 'error', title: i18n.ts.loginFailed, - text: i18n.ts.incorrectPassword, + text: i18n.ts.authenticationFailed, }); break; }