Merged PR 658: アカウント認証のお願い通知の実装 [U-102]

## 概要
[Task3321: アカウント認証のお願い通知の実装](https://paruru.nds-tyo.co.jp:8443/tfs/ReciproCollection/fa4924a4-d079-4fab-9fb5-a9a11eb205f0/_workitems/edit/3321)

- アカウント登録時の認証メールを送信する機能を追加しました。

## レビューポイント
- 既存のエラー処理はそのままにしていますが不自然な点はないでしょうか?

## UIの変更
- なし
## 動作確認状況
- ローカルで確認
This commit is contained in:
makabe.t 2023-12-25 05:38:28 +00:00
parent 95c058265e
commit 9f8ccc436f
4 changed files with 151 additions and 17 deletions

View File

@ -287,24 +287,11 @@ export class AccountsService {
}
try {
// メールの内容を構成
const { subject, text, html } =
await this.sendgridService.createMailContentFromEmailConfirm(
context,
account.id,
user.id,
email,
);
// メールを送信
await this.sendgridService.sendMail(
await this.sendgridService.sendMailWithU102(
context,
[email],
[],
this.mailFrom,
subject,
text,
html,
email,
account.id,
user.id,
);
} catch (e) {
this.logger.error(`[${context.getTrackingId()}] error=${e}`);

View File

@ -31,6 +31,8 @@ export class SendGridService {
private readonly templateEmailVerifyText: string;
private readonly templateU101Html: string;
private readonly templateU101Text: string;
private readonly templateU102Html: string;
private readonly templateU102Text: string;
private readonly templateU105Html: string;
private readonly templateU105Text: string;
private readonly templateU106Html: string;
@ -83,6 +85,14 @@ export class SendGridService {
path.resolve(__dirname, `../../templates/template_U_101.txt`),
'utf-8',
);
this.templateU102Html = readFileSync(
path.resolve(__dirname, `../../templates/template_U_102.html`),
'utf-8',
);
this.templateU102Text = readFileSync(
path.resolve(__dirname, `../../templates/template_U_102.txt`),
'utf-8',
);
this.templateU105Html = readFileSync(
path.resolve(__dirname, `../../templates/template_U_105.html`),
@ -326,6 +336,57 @@ export class SendGridService {
}
}
/**
* U-102使
* @param context
* @param adminEmail (primary)
* @param accountId ID
* @param userId ID
* @returns mail with u102
*/
async sendMailWithU102(
context: Context,
adminEmail: string,
accountId: number,
userId: number,
): Promise<void> {
this.logger.log(
`[IN] [${context.getTrackingId()}] ${this.sendMailWithU102.name}`,
);
try {
const privateKey = getPrivateKey(this.configService);
const token = sign<{ accountId: number; userId: number; email: string }>(
{
accountId,
userId,
email: adminEmail,
},
this.emailConfirmLifetime,
privateKey,
);
const path = 'mail-confirm/';
const verifyUrl = `${this.appDomain}${path}?verify=${token}`;
const subject = 'User Registration Notification [U-102]';
const html = this.templateU102Html.replaceAll(VERIFY_LINK, verifyUrl);
const text = this.templateU102Text.replaceAll(VERIFY_LINK, verifyUrl);
await this.sendMail(
context,
[adminEmail],
[],
this.mailFrom,
subject,
text,
html,
);
} finally {
this.logger.log(
`[OUT] [${context.getTrackingId()}] ${this.sendMailWithU102.name}`,
);
}
}
/**
* U-105使
* @param context

View File

@ -0,0 +1,60 @@
<html>
<head>
<title>User Registration Notification [U-102]</title>
</head>
<body>
<div>
<h3>&lt;English&gt;</h3>
<p>
Your user information has been registered within the ODMS Cloud by
yourself. To complete your user registration, you must verify your email
address. Please verify by clicking on the link below. Once the
registration is completed, a notification window will appear confirming
that your user information has been verified.
</p>
<p>URL: <a href="$VERIFY_LINK$">$VERIFY_LINK$</a></p>
<p>
If you have received this e-mail in error, please delete this e-mail
from your system.<br />
This is an automatically generated e-mail and this mailbox is not
monitored. Please do not reply.
</p>
</div>
<div>
<h3>&lt;Deutsch&gt;</h3>
<p>
Ihre Benutzerinformationen wurden von Ihnen selbst in der ODMS Cloud
registriert. Um Ihre Benutzerregistrierung abzuschließen, müssen Sie
Ihre E-Mail-Adresse bestätigen. Bitte überprüfen Sie dies, indem Sie auf
den untenstehenden Link klicken. Sobald die Registrierung abgeschlossen
ist, erscheint ein Benachrichtigungsfenster, das bestätigt, dass Ihre
Benutzerinformationen überprüft wurden.
</p>
<p>URL: <a href="$VERIFY_LINK$">$VERIFY_LINK$</a></p>
<p>
Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie
diese E-Mail bitte aus Ihrem System.<br />
Dies ist eine automatisch generierte E-Mail und dieses Postfach wird
nicht überwacht. Bitte nicht antworten.
</p>
</div>
<div>
<h3>&lt;Français&gt;</h3>
<p>
Vos informations utilisateur ont été enregistrées par vous-même dans le
cloud ODMS. Pour finaliser votre inscription d'utilisateur, vous devez
vérifier votre adresse e-mail. Veuillez vérifier en cliquant sur le lien
ci-dessous. Une fois l'inscription terminée, une fenêtre de notification
apparaîtra confirmant que vos informations d'utilisateur ont été
vérifiées.
</p>
<p>URL: <a href="$VERIFY_LINK$">$VERIFY_LINK$</a></p>
<p>
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail
de votre système.<br />
Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres
n'est pas surveillée. Merci de ne pas répondre.
</p>
</div>
</body>
</html>

View File

@ -0,0 +1,26 @@
<English>
Your user information has been registered within the ODMS Cloud by yourself. To complete your user registration, you must verify your email address. Please verify by clicking on the link below. Once the registration is completed, a notification window will appear confirming that your user information has been verified.
URL: $VERIFY_LINK$
If you have received this e-mail in error, please delete this e-mail from your system.
This is an automatically generated e-mail and this mailbox is not monitored. Please do not reply.
<Deutsch>
Ihre Benutzerinformationen wurden von Ihnen selbst in der ODMS Cloud registriert. Um Ihre Benutzerregistrierung abzuschließen, müssen Sie Ihre E-Mail-Adresse bestätigen. Bitte überprüfen Sie dies, indem Sie auf den untenstehenden Link klicken. Sobald die Registrierung abgeschlossen ist, erscheint ein Benachrichtigungsfenster, das bestätigt, dass Ihre Benutzerinformationen überprüft wurden.
URL: $VERIFY_LINK$
Wenn Sie diese E-Mail fälschlicherweise erhalten haben, löschen Sie diese E-Mail bitte aus Ihrem System.
Dies ist eine automatisch generierte E-Mail und dieses Postfach wird nicht überwacht. Bitte nicht antworten.
<Français>
Vos informations utilisateur ont été enregistrées par vous-même dans le cloud ODMS. Pour finaliser votre inscription d'utilisateur, vous devez vérifier votre adresse e-mail. Veuillez vérifier en cliquant sur le lien ci-dessous. Une fois l'inscription terminée, une fenêtre de notification apparaîtra confirmant que vos informations d'utilisateur ont été vérifiées.
URL: $VERIFY_LINK$
Si vous avez reçu cet e-mail par erreur, veuillez supprimer cet e-mail de votre système.
Il s'agit d'un e-mail généré automatiquement et cette boîte aux lettres n'est pas surveillée. Merci de ne pas répondre.