From cad3a99f705ec51c07526386eb959a55f8836806 Mon Sep 17 00:00:00 2001 From: "maruyama.t" Date: Thu, 29 Feb 2024 12:50:17 +0000 Subject: [PATCH] =?UTF-8?q?Merged=20PR=20794:=20=E7=99=BB=E9=8C=B2?= =?UTF-8?q?=E3=83=84=E3=83=BC=E3=83=AB=E3=81=AB=E3=83=AD=E3=82=B0=E3=82=92?= =?UTF-8?q?=E4=BB=95=E8=BE=BC=E3=82=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 概要 [Task3839: 登録ツールにログを仕込む](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3839) 登録ツールが途中で動かなくなってしまう原因調査のために各関数にログを仕込みました。 ## レビューポイント - 特になし ## 動作確認状況 - ローカルで確認 ## 補足 - 相談、参考資料などがあれば --- .../server/src/common/password/password.ts | 8 +++++++- .../server/src/features/accounts/accounts.service.ts | 3 +++ .../server/src/features/register/register.controller.ts | 3 +++ .../server/src/features/users/users.service.ts | 6 +++++- .../server/src/gateways/adb2c/adb2c.service.ts | 3 +++ 5 files changed, 21 insertions(+), 2 deletions(-) diff --git a/data_migration_tools/server/src/common/password/password.ts b/data_migration_tools/server/src/common/password/password.ts index 6fbe071..15d52ce 100644 --- a/data_migration_tools/server/src/common/password/password.ts +++ b/data_migration_tools/server/src/common/password/password.ts @@ -18,7 +18,8 @@ export const makePassword = (): string => { let autoGeneratedPassword: string = ""; while (!valid) { - // パスワードをランダムに決定 + autoGeneratedPassword = ""; + // パスワードをランダムに決定+ while (autoGeneratedPassword.length < passLength) { // 上で決定したcharsの中からランダムに1文字ずつ追加 const index = Math.floor(Math.random() * chars.length); @@ -30,6 +31,11 @@ export const makePassword = (): string => { valid = autoGeneratedPassword.length == passLength && charaTypePattern.test(autoGeneratedPassword); + if (!valid) { + // autoGeneratedPasswordをログに出す + console.log("Password is not valid"); + console.log(autoGeneratedPassword); + } } return autoGeneratedPassword; }; diff --git a/data_migration_tools/server/src/features/accounts/accounts.service.ts b/data_migration_tools/server/src/features/accounts/accounts.service.ts index 2954cbd..fdfb458 100644 --- a/data_migration_tools/server/src/features/accounts/accounts.service.ts +++ b/data_migration_tools/server/src/features/accounts/accounts.service.ts @@ -79,6 +79,7 @@ export class AccountsService { HttpStatus.INTERNAL_SERVER_ERROR ); } + this.logger.log("idpにユーザーを作成成功"); // メールアドレス重複エラー if (isConflictError(externalUser)) { @@ -90,6 +91,7 @@ export class AccountsService { HttpStatus.BAD_REQUEST ); } + this.logger.log("メールアドレスは重複していません"); let account: Account; let user: User; @@ -138,6 +140,7 @@ export class AccountsService { account.id, country ); + this.logger.log("コンテナー作成成功"); } catch (e) { this.logger.error(`[${context.getTrackingId()}] error=${e}`); this.logger.error( diff --git a/data_migration_tools/server/src/features/register/register.controller.ts b/data_migration_tools/server/src/features/register/register.controller.ts index cb36d2a..d9b968f 100644 --- a/data_migration_tools/server/src/features/register/register.controller.ts +++ b/data_migration_tools/server/src/features/register/register.controller.ts @@ -106,8 +106,10 @@ export class RegisterController { } for (const AccountsFile of accountsObject) { + this.logger.log("ランダムパスワード生成開始"); // ランダムなパスワードを生成する const ramdomPassword = makePassword(); + this.logger.log("ランダムパスワード生成完了"); // roleの設定 // roleの値がnullなら"none"、null以外ならroleの値、 // また、roleの値が"author"なら"author"を設定 @@ -123,6 +125,7 @@ export class RegisterController { // ありえないが、roleの値が"none"または"author"の文字列以外の場合はエラーを返す throw new Error("Invalid role value"); } + this.logger.log("account生成開始"); await this.accountsService.createAccount( context, AccountsFile.companyName, diff --git a/data_migration_tools/server/src/features/users/users.service.ts b/data_migration_tools/server/src/features/users/users.service.ts index cb639cd..8134462 100644 --- a/data_migration_tools/server/src/features/users/users.service.ts +++ b/data_migration_tools/server/src/features/users/users.service.ts @@ -74,6 +74,9 @@ export class UsersService { accountId, authorId ); + this.logger.log( + `[${context.getTrackingId()}] isAuthorIdDuplicated=${isAuthorIdDuplicated}` + ); } catch (e) { this.logger.error(`[${context.getTrackingId()}] error=${e}`); throw new HttpException( @@ -88,9 +91,10 @@ export class UsersService { ); } } - + this.logger.log("ランダムパスワード生成開始"); // ランダムなパスワードを生成する const ramdomPassword = makePassword(); + this.logger.log("ランダムパスワード生成完了"); //Azure AD B2Cにユーザーを新規登録する let externalUser: { sub: string } | ConflictError; diff --git a/data_migration_tools/server/src/gateways/adb2c/adb2c.service.ts b/data_migration_tools/server/src/gateways/adb2c/adb2c.service.ts index 5ba0f0e..5dbe646 100644 --- a/data_migration_tools/server/src/gateways/adb2c/adb2c.service.ts +++ b/data_migration_tools/server/src/gateways/adb2c/adb2c.service.ts @@ -82,6 +82,9 @@ export class AdB2cService { }, ], }); + this.logger.log( + `[${context.getTrackingId()}] [ADB2C CREATE] newUser: ${newUser}` + ); return { sub: newUser.id }; } catch (e) { this.logger.error(`[${context.getTrackingId()}] error=${e}`);