From a0da277c05be03ccb0dabe424c846737a52e32af Mon Sep 17 00:00:00 2001 From: "makabe.t" Date: Fri, 8 Dec 2023 02:14:25 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20607:=20=E3=83=A1=E3=83=BC?= =?UTF-8?q?=E3=83=AB=E3=82=A2=E3=83=89=E3=83=AC=E3=82=B9=E5=85=A5=E5=8A=9B?= =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3232: メールアドレス入力チェックの修正](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3232) - メールアドレス入力に対して規約に則ったチェックを実施するように修正しました。 - 画面での入力チェックとAPIのバリデーションを修正しています。 ## レビューポイント - クライアントのチェック内容は規約に則った内容になっているでしょうか? - 正規表現の構文として不自然な点はないでしょうか? - サーバー側のチェックをIsEmail+禁止文字の追加という形で対応していますが適切でしょうか? ## UIの変更 - なし ## 動作確認状況 - ローカルで確認 --- dictation_client/src/features/partner/selectors.ts | 5 ++++- dictation_client/src/features/signup/selectors.ts | 4 +++- dictation_client/src/features/user/selectors.ts | 5 ++++- dictation_server/src/features/accounts/types/types.ts | 4 ++-- dictation_server/src/features/users/types/types.ts | 3 ++- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/dictation_client/src/features/partner/selectors.ts b/dictation_client/src/features/partner/selectors.ts index e07fd82..061f8b1 100644 --- a/dictation_client/src/features/partner/selectors.ts +++ b/dictation_client/src/features/partner/selectors.ts @@ -8,8 +8,11 @@ export const selectInputValidationErrors = (state: RootState) => { const hasErrorEmptyAdminName = state.partner.apps.addPartner.adminName === ""; const hasErrorEmptyEmail = state.partner.apps.addPartner.email === ""; + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; + const hasErrorIncorrectEmail = - (state.partner.apps.addPartner.email as string).match(/^[^@]+@[^@]+$/) + (state.partner.apps.addPartner.email as string).match(emailPattern) ?.length !== 1; return { diff --git a/dictation_client/src/features/signup/selectors.ts b/dictation_client/src/features/signup/selectors.ts index 823347f..29e3206 100644 --- a/dictation_client/src/features/signup/selectors.ts +++ b/dictation_client/src/features/signup/selectors.ts @@ -16,8 +16,10 @@ export const selectInputValidationErrors = (state: RootState) => { state.signup.apps.password ); + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; const hasErrorIncorrectEmail = - (state.signup.apps.email as string).match(/^[^@]+@[^@]+$/)?.length !== 1; + (state.signup.apps.email as string).match(emailPattern)?.length !== 1; return { hasErrorEmptyEmail, diff --git a/dictation_client/src/features/user/selectors.ts b/dictation_client/src/features/user/selectors.ts index 0fd057d..e1e3cf1 100644 --- a/dictation_client/src/features/user/selectors.ts +++ b/dictation_client/src/features/user/selectors.ts @@ -26,7 +26,10 @@ export const selectInputValidationErrors = (state: RootState) => { role ); - const hasErrorIncorrectEmail = email.match(/^[^@]+@[^@]+$/)?.length !== 1; + const emailPattern = + /^[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]+@[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*\.[a-zA-Z0-9!#$%&'_`/=~+\-?^{|}.]*[a-zA-Z]$/; + + const hasErrorIncorrectEmail = email.match(emailPattern)?.length !== 1; const hasErrorIncorrectEncryptionPassword = checkErrorIncorrectEncryptionPassword(encryptionPassword, role, encryption); diff --git a/dictation_server/src/features/accounts/types/types.ts b/dictation_server/src/features/accounts/types/types.ts index 276fd0e..6e45d8e 100644 --- a/dictation_server/src/features/accounts/types/types.ts +++ b/dictation_server/src/features/accounts/types/types.ts @@ -38,7 +38,7 @@ export class CreateAccountRequest { @ApiProperty() adminName: string; @ApiProperty() - @IsEmail() + @IsEmail({ blacklisted_chars: '*' }) adminMail: string; @ApiProperty() @IsAdminPasswordvalid() @@ -244,7 +244,7 @@ export class CreatePartnerAccountRequest { @ApiProperty() adminName: string; @ApiProperty() - @IsEmail() + @IsEmail({ blacklisted_chars: '*' }) email: string; } diff --git a/dictation_server/src/features/users/types/types.ts b/dictation_server/src/features/users/types/types.ts index d21f72d..c6bcb75 100644 --- a/dictation_server/src/features/users/types/types.ts +++ b/dictation_server/src/features/users/types/types.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsIn } from 'class-validator'; +import { IsEmail, IsIn } from 'class-validator'; import { TASK_LIST_SORTABLE_ATTRIBUTES, USER_LICENSE_STATUS, @@ -88,6 +88,7 @@ export class SignupRequest { authorId?: string; @ApiProperty() + @IsEmail({ blacklisted_chars: '*' }) email: string; @ApiProperty()