Merged PR 595: 各service.tsのoutログ追加
## 概要 [Task3162: licenses.service.tsのoutログ追加](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3162) - 何をどう変更したか、追加したライブラリなど ・licenses.service.tsのolicenseOrdersとissueCardLicenseKeysの[OUT]ログを追加 ・横展開として他のservice.tsでOUT、INログが不足している場合は追加する ## 動作確認状況 - ユニットテスト
This commit is contained in:
parent
ef376d3027
commit
15fa10e265
@ -152,6 +152,10 @@ export class AccountsService {
|
|||||||
makeErrorResponse('E009999'),
|
makeErrorResponse('E009999'),
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.getLicenseSummary.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -179,7 +183,7 @@ export class AccountsService {
|
|||||||
} | params: { ` +
|
} | params: { ` +
|
||||||
`dealerAccountId: ${dealerAccountId}, ` +
|
`dealerAccountId: ${dealerAccountId}, ` +
|
||||||
`role: ${role}, ` +
|
`role: ${role}, ` +
|
||||||
`acceptedEulaVersion: ${acceptedEulaVersion} }, ` +
|
`acceptedEulaVersion: ${acceptedEulaVersion}, ` +
|
||||||
`acceptedDpaVersion: ${acceptedDpaVersion} };`,
|
`acceptedDpaVersion: ${acceptedDpaVersion} };`,
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@ -333,6 +337,11 @@ export class AccountsService {
|
|||||||
externalUserId: string,
|
externalUserId: string,
|
||||||
context: Context,
|
context: Context,
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${
|
||||||
|
this.createAccount.name
|
||||||
|
} | params: { ` + `externalUserId: ${externalUserId}};`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
await this.adB2cService.deleteUser(externalUserId, context);
|
await this.adB2cService.deleteUser(externalUserId, context);
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
@ -344,6 +353,10 @@ export class AccountsService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete externalUser: ${externalUserId}`,
|
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete externalUser: ${externalUserId}`,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.deleteAdB2cUser.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +381,10 @@ export class AccountsService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete account: ${accountId}, user: ${userId}`,
|
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete account: ${accountId}, user: ${userId}`,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.deleteAccount.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -396,6 +413,10 @@ export class AccountsService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete container: ${accountId}, country: ${country}`,
|
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete container: ${accountId}, country: ${country}`,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.deleteBlobContainer.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1184,6 +1205,10 @@ export class AccountsService {
|
|||||||
makeErrorResponse('E009999'),
|
makeErrorResponse('E009999'),
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.createTypistGroup.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -119,7 +119,7 @@ export class AuthService {
|
|||||||
const privateKey = getPrivateKey(this.configService);
|
const privateKey = getPrivateKey(this.configService);
|
||||||
|
|
||||||
// ユーザーのロールを設定
|
// ユーザーのロールを設定
|
||||||
const role = this.getUserRole(user.role);
|
const role = this.getUserRole(context, user.role);
|
||||||
|
|
||||||
const token = sign<RefreshToken>(
|
const token = sign<RefreshToken>(
|
||||||
{
|
{
|
||||||
@ -250,7 +250,7 @@ export class AuthService {
|
|||||||
const privateKey = getPrivateKey(this.configService);
|
const privateKey = getPrivateKey(this.configService);
|
||||||
|
|
||||||
// ユーザーのロールを設定
|
// ユーザーのロールを設定
|
||||||
const role = this.getUserRole(adminUser.role);
|
const role = this.getUserRole(context, adminUser.role);
|
||||||
|
|
||||||
const token = sign<RefreshToken>(
|
const token = sign<RefreshToken>(
|
||||||
{
|
{
|
||||||
@ -540,6 +540,7 @@ export class AuthService {
|
|||||||
case jwt.JsonWebTokenError:
|
case jwt.JsonWebTokenError:
|
||||||
// メッセージごとにエラーを判定しHTTPエラーを生成
|
// メッセージごとにエラーを判定しHTTPエラーを生成
|
||||||
throw this.makeHttpErrorFromJsonWebTokenErrorMessage(
|
throw this.makeHttpErrorFromJsonWebTokenErrorMessage(
|
||||||
|
context,
|
||||||
message,
|
message,
|
||||||
issuer,
|
issuer,
|
||||||
);
|
);
|
||||||
@ -561,6 +562,9 @@ export class AuthService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPublicKeyFromJwk(context: Context, jwkKey: JwkSignKey): string {
|
getPublicKeyFromJwk(context: Context, jwkKey: JwkSignKey): string {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${this.getPublicKeyFromJwk.name}`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
// JWK形式のJSONなのでJWTの公開鍵として使えるようにPEM形式に変換
|
// JWK形式のJSONなのでJWTの公開鍵として使えるようにPEM形式に変換
|
||||||
const publicKey = jwkToPem({
|
const publicKey = jwkToPem({
|
||||||
@ -584,9 +588,16 @@ export class AuthService {
|
|||||||
* JWT検証時のError、JsonWebTokenErrorをメッセージごとに仕分けてHTTPエラーを生成
|
* JWT検証時のError、JsonWebTokenErrorをメッセージごとに仕分けてHTTPエラーを生成
|
||||||
*/
|
*/
|
||||||
makeHttpErrorFromJsonWebTokenErrorMessage = (
|
makeHttpErrorFromJsonWebTokenErrorMessage = (
|
||||||
|
context: Context,
|
||||||
message: string,
|
message: string,
|
||||||
issuer: string,
|
issuer: string,
|
||||||
): Error => {
|
): Error => {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${
|
||||||
|
this.makeHttpErrorFromJsonWebTokenErrorMessage.name
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
try {
|
||||||
// 署名が不正
|
// 署名が不正
|
||||||
if (message === 'invalid signature') {
|
if (message === 'invalid signature') {
|
||||||
return new HttpException(
|
return new HttpException(
|
||||||
@ -613,11 +624,26 @@ export class AuthService {
|
|||||||
makeErrorResponse('E000101'),
|
makeErrorResponse('E000101'),
|
||||||
HttpStatus.UNAUTHORIZED,
|
HttpStatus.UNAUTHORIZED,
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${
|
||||||
|
this.makeHttpErrorFromJsonWebTokenErrorMessage.name
|
||||||
|
}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* トークンに設定するユーザーのロールを取得
|
* トークンに設定するユーザーのロールを取得
|
||||||
*/
|
*/
|
||||||
getUserRole = (role: string): string => {
|
getUserRole = (context: Context, role: string): string => {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${this.getUserRole.name}`,
|
||||||
|
);
|
||||||
|
try {
|
||||||
// ユーザーのロールを設定
|
// ユーザーのロールを設定
|
||||||
// 万一不正なRoleが登録されていた場合、そのままDBの値を使用すると不正なロールのリフレッシュトークンが発行されるため、
|
// 万一不正なRoleが登録されていた場合、そのままDBの値を使用すると不正なロールのリフレッシュトークンが発行されるため、
|
||||||
// ロールの設定値はDBに保存したRoleの値を直接トークンに入れないように定数で設定する
|
// ロールの設定値はDBに保存したRoleの値を直接トークンに入れないように定数で設定する
|
||||||
@ -633,6 +659,14 @@ export class AuthService {
|
|||||||
`Role from DB is unexpected value. role=${role}`,
|
`Role from DB is unexpected value. role=${role}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.getUserRole.name}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import {
|
|||||||
import { LicensesRepositoryService } from '../../repositories/licenses/licenses.repository.service';
|
import { LicensesRepositoryService } from '../../repositories/licenses/licenses.repository.service';
|
||||||
import { UserNotFoundError } from '../../repositories/users/errors/types';
|
import { UserNotFoundError } from '../../repositories/users/errors/types';
|
||||||
import {
|
import {
|
||||||
DateWithZeroTime,
|
|
||||||
GetAllocatableLicensesResponse,
|
GetAllocatableLicensesResponse,
|
||||||
IssueCardLicensesResponse,
|
IssueCardLicensesResponse,
|
||||||
} from './types/types';
|
} from './types/types';
|
||||||
@ -113,6 +112,10 @@ export class LicensesService {
|
|||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.licenseOrders.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async issueCardLicenseKeys(
|
async issueCardLicenseKeys(
|
||||||
@ -164,6 +167,10 @@ export class LicensesService {
|
|||||||
makeErrorResponse('E009999'),
|
makeErrorResponse('E009999'),
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.issueCardLicenseKeys.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
|
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
|
||||||
import { TasksRepositoryService } from '../../repositories/tasks/tasks.repository.service';
|
import { TasksRepositoryService } from '../../repositories/tasks/tasks.repository.service';
|
||||||
import { AccessToken } from '../../common/token';
|
|
||||||
import { Assignee, Task } from './types/types';
|
import { Assignee, Task } from './types/types';
|
||||||
import { Task as TaskEntity } from '../../repositories/tasks/entity/task.entity';
|
import { Task as TaskEntity } from '../../repositories/tasks/entity/task.entity';
|
||||||
import { createTasks } from './types/convert';
|
import { createTasks } from './types/convert';
|
||||||
@ -625,6 +624,10 @@ export class TasksService {
|
|||||||
...new Set(assigneesExternalIds.concat(typistExternalIds)),
|
...new Set(assigneesExternalIds.concat(typistExternalIds)),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.getB2cUsers.name}`,
|
||||||
|
);
|
||||||
|
|
||||||
// B2Cからユーザー名を取得する
|
// B2Cからユーザー名を取得する
|
||||||
return await this.adB2cService.getUsers(context, distinctedExternalIds);
|
return await this.adB2cService.getUsers(context, distinctedExternalIds);
|
||||||
}
|
}
|
||||||
@ -769,5 +772,8 @@ export class TasksService {
|
|||||||
priority: file.priority === '00' ? 'Normal' : 'High',
|
priority: file.priority === '00' ? 'Normal' : 'High',
|
||||||
uploadedAt: file.uploaded_at.toISOString(),
|
uploadedAt: file.uploaded_at.toISOString(),
|
||||||
});
|
});
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.sendNotify.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -117,6 +117,10 @@ export class UsersService {
|
|||||||
makeErrorResponse('E009999'),
|
makeErrorResponse('E009999'),
|
||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.confirmUser.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,6 +317,11 @@ export class UsersService {
|
|||||||
// Azure AD B2Cに登録したユーザー情報を削除する
|
// Azure AD B2Cに登録したユーザー情報を削除する
|
||||||
// TODO 「タスク 2452: リトライ処理を入れる箇所を検討し、実装する」の候補
|
// TODO 「タスク 2452: リトライ処理を入れる箇所を検討し、実装する」の候補
|
||||||
private async deleteB2cUser(externalUserId: string, context: Context) {
|
private async deleteB2cUser(externalUserId: string, context: Context) {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${
|
||||||
|
this.deleteB2cUser.name
|
||||||
|
} | params: { externalUserId: ${externalUserId} }`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
await this.adB2cService.deleteUser(externalUserId, context);
|
await this.adB2cService.deleteUser(externalUserId, context);
|
||||||
this.logger.log(
|
this.logger.log(
|
||||||
@ -323,11 +332,20 @@ export class UsersService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete externalUser: ${externalUserId}`,
|
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete externalUser: ${externalUserId}`,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.deleteB2cUser.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// DBに登録したユーザー情報を削除する
|
// DBに登録したユーザー情報を削除する
|
||||||
private async deleteUser(userId: number, context: Context) {
|
private async deleteUser(userId: number, context: Context) {
|
||||||
|
this.logger.log(
|
||||||
|
`[IN] [${context.getTrackingId()}] ${
|
||||||
|
this.deleteUser.name
|
||||||
|
} | params: { userId: ${userId} }`,
|
||||||
|
);
|
||||||
try {
|
try {
|
||||||
await this.usersRepository.deleteNormalUser(userId);
|
await this.usersRepository.deleteNormalUser(userId);
|
||||||
this.logger.log(`[${context.getTrackingId()}] delete user: ${userId}`);
|
this.logger.log(`[${context.getTrackingId()}] delete user: ${userId}`);
|
||||||
@ -336,6 +354,10 @@ export class UsersService {
|
|||||||
this.logger.error(
|
this.logger.error(
|
||||||
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete user: ${userId}`,
|
`${MANUAL_RECOVERY_REQUIRED} [${context.getTrackingId()}] Failed to delete user: ${userId}`,
|
||||||
);
|
);
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.deleteUser.name}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +390,7 @@ export class UsersService {
|
|||||||
`encryption: ${encryption}, ` +
|
`encryption: ${encryption}, ` +
|
||||||
`prompt: ${prompt} };`,
|
`prompt: ${prompt} };`,
|
||||||
);
|
);
|
||||||
|
try {
|
||||||
switch (role) {
|
switch (role) {
|
||||||
case USER_ROLES.NONE:
|
case USER_ROLES.NONE:
|
||||||
case USER_ROLES.TYPIST:
|
case USER_ROLES.TYPIST:
|
||||||
@ -410,6 +433,14 @@ export class UsersService {
|
|||||||
HttpStatus.INTERNAL_SERVER_ERROR,
|
HttpStatus.INTERNAL_SERVER_ERROR,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} catch (e) {
|
||||||
|
this.logger.error(`[${context.getTrackingId()}] error=${e}`);
|
||||||
|
return e;
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${this.createNewUserInfo.name}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -486,6 +517,12 @@ export class UsersService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
this.logger.log(
|
||||||
|
`[OUT] [${context.getTrackingId()}] ${
|
||||||
|
this.confirmUserAndInitPassword.name
|
||||||
|
}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user