This repository has been archived by the owner on Dec 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implements email service and sign-up service
- Loading branch information
1 parent
9689200
commit d3d5b75
Showing
16 changed files
with
1,716 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,8 @@ resource "aws_ecs_task_definition" "api" { | |
redis_port = var.redis_port, | ||
jwt_secret = var.jwt_secret, | ||
cdn_base_url = var.cdn_base_url, | ||
aws_cdn_bucket_name = var.aws_cdn_bucket_name | ||
aws_cdn_bucket_name = var.aws_cdn_bucket_name, | ||
nodemailer_from = "SKKU ROYALS <[email protected]>" | ||
}) | ||
|
||
execution_role_arn = aws_iam_role.ecs_task_execution_role.arn | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { Module } from '@nestjs/common' | ||
import { EmailService } from './email.service' | ||
|
||
@Module({ | ||
providers: [EmailService], | ||
exports: [EmailService] | ||
}) | ||
export class EmailModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { MailerService } from '@nestjs-modules/mailer' | ||
import { Service } from '@libs/decorator' | ||
|
||
@Service() | ||
export class EmailService { | ||
constructor(private readonly mailerService: MailerService) {} | ||
|
||
async sendEmailAuthenticationPin(email: string, pin: string): Promise<void> { | ||
await this.mailerService.sendMail({ | ||
to: email, | ||
subject: '[SKKU ROYALS] 이메일 인증', | ||
template: 'email-auth', | ||
context: { pin } | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import type { | ||
MailerOptions, | ||
MailerOptionsFactory | ||
} from '@nestjs-modules/mailer' | ||
import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter' | ||
import { Injectable } from '@nestjs/common' | ||
import { ConfigService } from '@nestjs/config' | ||
import { SESClient } from '@aws-sdk/client-ses' | ||
import { defaultProvider } from '@aws-sdk/credential-provider-node' | ||
import { calculateSesSmtpPassword } from '@pepperize/cdk-ses-smtp-credentials' | ||
import { join } from 'path' | ||
|
||
@Injectable() | ||
export class MailerConfigService implements MailerOptionsFactory { | ||
constructor(private readonly config: ConfigService) {} | ||
|
||
createMailerOptions(): MailerOptions { | ||
return { | ||
transport: this.config.get('NODEMAILER_HOST') | ||
? { | ||
host: this.config.get('NODEMAILER_HOST'), | ||
auth: { | ||
user: this.config.get('NODEMAILER_USER'), | ||
pass: calculateSesSmtpPassword( | ||
this.config.get('NODEMAILER_PASS'), | ||
'ap-northeast-2' | ||
) | ||
} | ||
} | ||
: { | ||
SES: new SESClient({ | ||
region: 'ap-northeast-2', | ||
credentials: defaultProvider() | ||
}) | ||
}, | ||
defaults: { | ||
from: this.config.get('NODEMAILER_FROM') | ||
}, | ||
template: { | ||
dir: join(__dirname, 'email/templates'), | ||
adapter: new HandlebarsAdapter(), | ||
options: { | ||
strict: true | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<style> | ||
* { margin: 0; padding: 0; font-family: 'Manrope', Helvetica, Arial, | ||
sans-serif; } body { background: #ececec; } p { margin: 16px 0; font-size: | ||
16px; line-height: 24px; } h1 { margin-top: 32px; margin-bottom: 16px; | ||
font-size: 24px; } #logo { display: block; margin-left: auto; margin-right: | ||
auto; } #backgroundTable { margin-left: auto; margin-right: auto; } #mainTable | ||
{ max-width: 420px; background: white; margin: 20px; padding: 24px; | ||
border-radius: 12px; box-shadow: 4px 4px 12px 4px rgba(0, 0, 0, 0.15); } | ||
#backgroundTable { padding: 20px; } #pin { font-size: 36px; text-align: | ||
center; margin: 60px 0; letter-spacing: 12px; } #team { margin-top: 40px; | ||
text-align: right; } footer { border-top: 1px solid #777; color: #777; | ||
margin-top: 40px; padding-top: 20px; font-size: 14px; } | ||
</style> | ||
|
||
<table id='backgroundTable' cellpadding='0' cellspacing='0' border='0'> | ||
<tr> | ||
<td> | ||
<table id='mainTable' cellpadding='0' cellspacing='0' align='center'> | ||
<tr> | ||
<td> | ||
<img | ||
src='https://github.com/skku-royals/official-webpage/blob/main/frontend/public/text-logo-light.png?raw=true' | ||
height='72' | ||
alt='Royals' | ||
id='logo' | ||
/> | ||
<h1>Email Authentication</h1> | ||
<p>You have requested an email authentication. Put the pin numbers | ||
below into the form.</p> | ||
<p id='pin'>{{pin}}</p> | ||
<p>If you did not request to register or change your information, | ||
please ignore this email.</p> | ||
<p id='team'>성균관대학교 미식축구부 로얄스</p> | ||
<footer> | ||
Visit our website at | ||
<a href='https://skku-royals.com'>skku-royals.com</a>. | ||
</footer> | ||
</td> | ||
</tr> | ||
</table> | ||
</td> | ||
</tr> | ||
</table> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.