-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: mail lambda custom message (#246)
* fix: mail lambda custom message * fix: no-hoist in wrong place * fix: custom mailer now uses reapit-config * fix: add ga-tag to config
- Loading branch information
Showing
15 changed files
with
146 additions
and
39 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 |
---|---|---|
|
@@ -56,3 +56,4 @@ elements/public | |
out* | ||
package-lock.json | ||
.env | ||
invite-developers.js |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { customMailer } from '../custom-mailer' | ||
import { CognitoUserPoolTriggerEvent, Context } from 'aws-lambda' | ||
import { confirmRegistrationTemplate, forgotPasswordTemplate } from '../templates/index' | ||
import { confirmRegistrationTemplate, forgotPasswordTemplate, adminUserInviteTemplate } from '../templates/index' | ||
|
||
const context = {} as Context | ||
|
||
|
@@ -93,6 +93,33 @@ describe('customMailer', () => { | |
expect(callback).toHaveBeenCalledWith(null, event) | ||
}) | ||
|
||
it('should call the callback with an updated event if trigger source is CustomMessage_AdminCreateUser', async () => { | ||
process.env.COGNITO_USERPOOL_ID = 'SOME_ID' | ||
process.env.MARKET_PLACE_URL = 'SOME_URL' | ||
const callback = jest.fn() | ||
const event = { | ||
triggerSource: 'CustomMessage_AdminCreateUser', | ||
userPoolId: process.env.COGNITO_USERPOOL_ID, | ||
response: {}, | ||
request: { | ||
codeParameter: 'SOME_CODE', | ||
userAttributes: { | ||
email: '[email protected]', | ||
}, | ||
}, | ||
} as Partial<CognitoUserPoolTriggerEvent> | ||
|
||
await customMailer(event as CognitoUserPoolTriggerEvent, context, callback) | ||
expect(event.response).toEqual({ | ||
emailSubject: 'Welcome to Reapit Foundations', | ||
emailMessage: await adminUserInviteTemplate({ | ||
userName: event.request?.userAttributes.email as string, | ||
url: 'SOME_URL/developer/login', | ||
}), | ||
}) | ||
expect(callback).toHaveBeenCalledWith(null, event) | ||
}) | ||
|
||
afterEach(() => { | ||
jest.resetAllMocks() | ||
}) | ||
|
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
25 changes: 25 additions & 0 deletions
25
packages/cognito-custom-mail-lambda/src/mailer/templates/ejs/admin-user-invite.ejs
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,25 @@ | ||
<article style="font-family: Arial, Helvetica, sans-serif;margin:0px;background-color:white;line-height: 1.5rem;"> | ||
<img style="width: 100%;" src="https://reapit-s3-policy-test.s3.eu-west-2.amazonaws.com/public/image-20191122-114228.png" /> | ||
<h1 style="text-align: center;font-size: 34px; font-style: normal;">Verify your account</h1> | ||
<div style="padding:0 20px 20px 50px;"> | ||
<p>Hi <%= userName %>,</p> | ||
<br /> | ||
<p>Welcome to Reapit Foundations.</p> | ||
<br /> | ||
<p>Please see below your temporary username and password. When you click the login link, you will be re-directed to a screen where you will be asked to change your password.</p> | ||
<br /> | ||
<p><strong>User Name: {username}</strong></p> | ||
<p><strong>Password: {####}</strong></p> | ||
<br /> | ||
<div style="text-align: left;"> | ||
<a style="border: solid thin #0061a8;padding: 10px;background-color: #0061a8;color: white;z-index: 1;text-decoration: none; font-style: normal;" href=<%= `${url}` %>>LOGIN</a> | ||
</div> | ||
<br /> | ||
<p>When you have changed your password, you will be asked to log in and will be re-directed to the developer portal.</p> | ||
<br /> | ||
<p>We look forward to seeing what you build!</p> | ||
<br /> | ||
<p>Best Regards,</p> | ||
<p>Reapit Team</p> | ||
</div> | ||
</article> |
2 changes: 1 addition & 1 deletion
2
packages/cognito-custom-mail-lambda/src/mailer/templates/ejs/confirm-registration.ejs
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
9 changes: 4 additions & 5 deletions
9
packages/cognito-custom-mail-lambda/src/mailer/templates/ejs/forgotten-password.ejs
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 |
---|---|---|
|
@@ -14,16 +14,17 @@ | |
<p>Some text</p> | ||
<p>Some text</p> | ||
<div style="text-align: center;"> | ||
<a style="border: solid thin #0061a8;padding: 10px;background-color: #0061a8;color: white;z-index: 1;text-decoration: none; font-style: normal;" href=<%= `https://dev.marketplace.reapit.com/register/confirm?userName=${userName}&verificationCode={####}` %>>CTA</a> | ||
<a style="border: solid thin #0061a8;padding: 10px;background-color: #0061a8;color: white;z-index: 1;text-decoration: none; font-style: normal;" href=<%= `https://dev.marketplace.reapit.cloud/register/confirm?userName=${userName}&verificationCode={####}` %>>CTA</a> | ||
</div> | ||
<p>Some text</p> | ||
<br /> | ||
<p>Best Regards,</p> | ||
<p>Reapit Team</p> | ||
</div> | ||
</article> | ||
<%-include('forgotten-password', {userName: '[email protected]', verificationCode: '123', url: 'https://dev.marketplace.reapit.com/developer/reset-password'}) %> | ||
<%-include('confirm-registration', {userName: '[email protected]', verificationCode: '123', url: 'https://dev.marketplace.reapit.com/register/confirm'}) %> | ||
<%-include('forgotten-password', {userName: '[email protected]', verificationCode: '123', url: 'https://dev.marketplace.reapit.cloud/developer/reset-password'}) %> | ||
<%-include('confirm-registration', {userName: '[email protected]', verificationCode: '123', url: 'https://dev.marketplace.reapit.cloud/register/confirm'}) %> | ||
<%-include('admin-user-invite', {userName: '[email protected]', verificationCode: '123'}, 'https://dev.marketplace.reapit.cloud/developer/login') %> | ||
</main> | ||
</body> | ||
</html> |
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
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 |
---|---|---|
|
@@ -5630,16 +5630,32 @@ awesome-typescript-loader@^5.2.1: | |
source-map-support "^0.5.3" | ||
webpack-log "^1.2.0" | ||
|
||
aws-lambda@^0.1.2: | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/aws-lambda/-/aws-lambda-0.1.2.tgz#19b1585075df31679597b976a5f1def61f12ccee" | ||
integrity sha1-GbFYUHXfMWeVl7l2pfHe9h8SzO4= | ||
aws-lambda@^1.0.5: | ||
version "1.0.5" | ||
resolved "https://registry.yarnpkg.com/aws-lambda/-/aws-lambda-1.0.5.tgz#9f40ca36da2aca8345230d6252c6e0da5a772dcf" | ||
integrity sha512-rRBZT5mitbeb/qdqHrFiymFQ8k+uc8WlN2Y16OhsCEZzYHKRqFzRirO7gIozDohNuu7T27S6w88KBFpI0cS1NQ== | ||
dependencies: | ||
aws-sdk "^*" | ||
commander "^2.5.0" | ||
dotenv "^0.4.0" | ||
aws-sdk "*" | ||
commander "^3.0.2" | ||
js-yaml "^3.13.1" | ||
watchpack "^2.0.0-beta.10" | ||
|
||
aws-sdk@^*, aws-sdk@^2.582.0: | ||
aws-sdk@*: | ||
version "2.615.0" | ||
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.615.0.tgz#36233df3ae603ad38cc4181e8d92c7d6e5dae16c" | ||
integrity sha512-ktkOQgJLTcsfLzy/GPfUiEJd09SeJPnUj7ZeXa0Wb2/JVIRDbSmyG/IYQqAvXWUcD4thuv2h9wbLgXyzvX8dtw== | ||
dependencies: | ||
buffer "4.9.1" | ||
events "1.1.1" | ||
ieee754 "1.1.13" | ||
jmespath "0.15.0" | ||
querystring "0.2.0" | ||
sax "1.2.1" | ||
url "0.10.3" | ||
uuid "3.3.2" | ||
xml2js "0.4.19" | ||
|
||
aws-sdk@^2.582.0: | ||
version "2.612.0" | ||
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.612.0.tgz#3af06638ec785bad10986b81ce265422fca552e3" | ||
integrity sha512-/oAeVw9okULGczQLNMAO3/w9sA2ubf/+iqRQRXRjrJXVUi7INV6qYnNzIXzy7GabOkN7xpZiTbVcU+Yij5yrxg== | ||
|
@@ -7537,11 +7553,16 @@ [email protected]: | |
resolved "https://registry.yarnpkg.com/commander/-/commander-2.17.1.tgz#bd77ab7de6de94205ceacc72f1716d29f20a77bf" | ||
integrity sha512-wPMUt6FnH2yzG95SA6mzjQOEKUU3aLaDEmzs1ti+1E9h+CsrZghRlqEM/EJ4KscsQVG8uNN4uVreUeT8+drlgg== | ||
|
||
commander@^2.11.0, commander@^2.18.0, commander@^2.19.0, commander@^2.20.0, commander@^2.5.0, commander@^2.9.0, commander@~2.20.3: | ||
commander@^2.11.0, commander@^2.18.0, commander@^2.19.0, commander@^2.20.0, commander@^2.9.0, commander@~2.20.3: | ||
version "2.20.3" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" | ||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== | ||
|
||
commander@^3.0.2: | ||
version "3.0.2" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-3.0.2.tgz#6837c3fb677ad9933d1cfba42dd14d5117d6b39e" | ||
integrity sha512-Gar0ASD4BDyKC4hl4DwHqDrmvjoxWKZigVnAbn5H1owvm4CxCPdb0HQDehwNYMJpla5+M2tPmPARzhtYuwpHow== | ||
|
||
commander@^4.0.0, commander@^4.0.1: | ||
version "4.1.1" | ||
resolved "https://registry.yarnpkg.com/commander/-/commander-4.1.1.tgz#9fd602bd936294e9e9ef46a3f4d6964044b18068" | ||
|
@@ -8964,11 +8985,6 @@ dotenv-webpack@^1.7.0: | |
dependencies: | ||
dotenv-defaults "^1.0.2" | ||
|
||
dotenv@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-0.4.0.tgz#f6fb351363c2d92207245c737802c9ab5ae1495a" | ||
integrity sha1-9vs1E2PC2SIHJFxzeALJq1rhSVo= | ||
|
||
dotenv@^6.2.0: | ||
version "6.2.0" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-6.2.0.tgz#941c0410535d942c8becf28d3f357dbd9d476064" | ||
|
@@ -11095,6 +11111,11 @@ glob-to-regexp@^0.3.0: | |
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" | ||
integrity sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs= | ||
|
||
glob-to-regexp@^0.4.1: | ||
version "0.4.1" | ||
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" | ||
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== | ||
|
||
glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4, glob@^7.1.6, glob@~7.1.1: | ||
version "7.1.6" | ||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" | ||
|
@@ -22851,6 +22872,14 @@ watchpack@^1.6.0: | |
graceful-fs "^4.1.2" | ||
neo-async "^2.5.0" | ||
|
||
watchpack@^2.0.0-beta.10: | ||
version "2.0.0-beta.12" | ||
resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-2.0.0-beta.12.tgz#bed6878b020c8f43f5b88b7031dfb2b2092755f5" | ||
integrity sha512-vUJN6XQCBqrUkyX74WNopUvASMLqgicYGA5nO/FwSfdmLQgrfy44Z+Jl2YHHHXy/gDO6RlbArR26YQGeIWfoAg== | ||
dependencies: | ||
glob-to-regexp "^0.4.1" | ||
graceful-fs "^4.1.2" | ||
|
||
wbuf@^1.1.0, wbuf@^1.7.3: | ||
version "1.7.3" | ||
resolved "https://registry.yarnpkg.com/wbuf/-/wbuf-1.7.3.tgz#c1d8d149316d3ea852848895cb6a0bfe887b87df" | ||
|