Skip to content
This repository was archived by the owner on Jan 5, 2022. It is now read-only.

Commit 8e5a2bd

Browse files
committed
Fixed registration error for empty email address
1 parent 587254a commit 8e5a2bd

File tree

7 files changed

+39
-1
lines changed

7 files changed

+39
-1
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
terraform-aws-cognito-auth-0.x.x (2018-xx-xx)
2+
3+
* Switched to admin-only user creation (API doesn't allow otherwise)
4+
* Fixed registration error for empty email address
5+
16
terraform-aws-cognito-auth-0.3.0 (2018-09-09)
27

38
* Added identity token expires timestamp to hash fragment

modules/api/lambda/package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

modules/api/lambda/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
},
2929
"dependencies": {
3030
"cookie": "^0.3.1",
31+
"email-validator": "^2.0.4",
3132
"jsonschema": "^1.2.4",
3233
"password-rules": "0.0.3",
3334
"uuid": "^3.2.1"

modules/api/lambda/src/clients/authentication/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
import { AWSError } from "aws-sdk"
24+
import { validate } from "email-validator"
2425
import * as uuid from "uuid/v4"
2526

2627
import { Client } from "clients"
@@ -106,6 +107,10 @@ export class AuthenticationClient extends Client {
106107
): Promise<VerificationCode> {
107108
const username = uuid()
108109

110+
/* Check if email address is valid */
111+
if (!validate(email))
112+
throw new Error("Invalid email address")
113+
109114
/* Register user with Cognito */
110115
await this.cognito.signUp({
111116
ClientId: process.env.COGNITO_USER_POOL_CLIENT_ID!,

modules/api/lambda/tests/suites/unit/clients/authentication/index.spec.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,20 @@ describe("clients/authentication", () => {
162162
}))
163163
})
164164

165+
/* Test: should reject on invalid email address */
166+
it("should reject on invalid email address", async done => {
167+
mockCognitoSignUpWithSuccess()
168+
mockVerificationIssueWithResult()
169+
try {
170+
const auth = new AuthenticationClient()
171+
await auth.register(chance.string(), password)
172+
done.fail()
173+
} catch (err) {
174+
expect(err).toEqual(new Error("Invalid email address"))
175+
done()
176+
}
177+
})
178+
165179
/* Test: should reject on verification error */
166180
it("should reject on verification error", async done => {
167181
const errMock = new Error()

modules/web/app/dist/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1"/> <meta name="robots" content="noindex, nofollow"/> <title>${cognito_identity_pool_name}</title> <base href="/"/> <meta name="config:api_base_path" content="${api_base_path}"/> <meta name="config:app_origin" content="${app_origin}"/> <meta name="config:cognito_identity_pool_name" content="${cognito_identity_pool_name}"/> <style>#root,body,html{height:100%;margin:0}</style> </head> <body> <div id="root"></div> <script type="text/javascript" src="vendor.7b8792aa00e545d8b454.bundle.js"></script><script type="text/javascript" src="main.3882070cea37393da427.bundle.js"></script></body> </html>
1+
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"/> <meta name="viewport" content="width=device-width,initial-scale=1"/> <meta name="robots" content="noindex, nofollow"/> <title>${cognito_identity_pool_name}</title> <base href="/"/> <meta name="config:api_base_path" content="${api_base_path}"/> <meta name="config:app_origin" content="${app_origin}"/> <meta name="config:cognito_identity_pool_name" content="${cognito_identity_pool_name}"/> <style>#root,body,html{height:100%;margin:0}html{background:#fafafa}@media (max-width:599.95px){html{background:0 0}}</style> </head> <body> <div id="root"></div> <script type="text/javascript" src="vendor.7b8792aa00e545d8b454.bundle.js"></script><script type="text/javascript" src="main.3882070cea37393da427.bundle.js"></script></body> </html>

modules/web/app/src/index.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,14 @@
3838
height: 100%;
3939
margin: 0;
4040
}
41+
html {
42+
background: #fafafa;
43+
}
44+
@media (max-width: 599.95px) {
45+
html {
46+
background: none;
47+
}
48+
}
4149
</style>
4250
</head>
4351
<body>

0 commit comments

Comments
 (0)