Merged PR 794: 登録ツールにログを仕込む

## 概要
[Task3839: 登録ツールにログを仕込む](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3839)

登録ツールが途中で動かなくなってしまう原因調査のために各関数にログを仕込みました。

## レビューポイント
- 特になし

## 動作確認状況
- ローカルで確認

## 補足
- 相談、参考資料などがあれば
This commit is contained in:
maruyama.t 2024-02-29 12:50:17 +00:00
parent 0ebd2ab17e
commit cad3a99f70
5 changed files with 21 additions and 2 deletions

View File

@ -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;
};

View File

@ -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(

View File

@ -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,

View File

@ -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;

View File

@ -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}`);