From ad7bf096e1d858cddb097fb9b32bfc2387b63894 Mon Sep 17 00:00:00 2001 From: tamaina Date: Tue, 15 Jul 2025 09:32:46 +0900 Subject: [PATCH] =?UTF-8?q?enhance(backend):=20username=E3=81=AB=E5=AF=BE?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=82=82prohibitedWordsForNameOfUser?= =?UTF-8?q?=E3=82=92=E9=81=A9=E7=94=A8=20(#16282)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * enhance(backend): usernameに対してもprohibitedWordsForNameOfUserを適用 Resolve #16281 * fix locales/index/d.ts --- locales/index.d.ts | 2 +- locales/ja-JP.yml | 2 +- packages/backend/src/core/SignupService.ts | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/locales/index.d.ts b/locales/index.d.ts index ceb3cc672d..8d757ff579 100644 --- a/locales/index.d.ts +++ b/locales/index.d.ts @@ -5231,7 +5231,7 @@ export interface Locale extends ILocale { */ "prohibitedWordsForNameOfUser": string; /** - * このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。 + * このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。ユーザー名(username)に対しても全て小文字に置き換えて検査します。 */ "prohibitedWordsForNameOfUserDescription": string; /** diff --git a/locales/ja-JP.yml b/locales/ja-JP.yml index 6af846f7ee..161edfe8bb 100644 --- a/locales/ja-JP.yml +++ b/locales/ja-JP.yml @@ -1303,7 +1303,7 @@ messageToFollower: "フォロワーへのメッセージ" target: "対象" testCaptchaWarning: "CAPTCHAのテストを目的とした機能です。本番環境で使用しないでください。" prohibitedWordsForNameOfUser: "禁止ワード(ユーザーの名前)" -prohibitedWordsForNameOfUserDescription: "このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。" +prohibitedWordsForNameOfUserDescription: "このリストに含まれる文字列がユーザーの名前に含まれる場合、ユーザーの名前の変更を拒否します。モデレーター権限を持つユーザーはこの制限の影響を受けません。ユーザー名(username)に対しても全て小文字に置き換えて検査します。" yourNameContainsProhibitedWords: "変更しようとした名前に禁止された文字列が含まれています" yourNameContainsProhibitedWordsDescription: "名前に禁止されている文字列が含まれています。この名前を使用したい場合は、サーバー管理者にお問い合わせください。" thisContentsAreMarkedAsSigninRequiredByAuthor: "投稿者により、表示にはログインが必要と設定されています" diff --git a/packages/backend/src/core/SignupService.ts b/packages/backend/src/core/SignupService.ts index 5462cb0b13..a85da62b86 100644 --- a/packages/backend/src/core/SignupService.ts +++ b/packages/backend/src/core/SignupService.ts @@ -93,6 +93,11 @@ export class SignupService { if (isPreserved) { throw new Error('USED_USERNAME'); } + + const hasProhibitedWords = this.utilityService.isKeyWordIncluded(username.toLowerCase(), this.meta.prohibitedWordsForNameOfUser); + if (hasProhibitedWords) { + throw new Error('USED_USERNAME'); + } } const keyPair = await new Promise((res, rej) =>