Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
fix: email TLD can be longer than 3 chars (#928)
Browse files Browse the repository at this point in the history
  • Loading branch information
SanketD92 authored Feb 21, 2022
1 parent 1465431 commit eab8ec9
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"minLength": 3,
"maxLength": 300,
"format": "email",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))"
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))"
},
"usernameInIdp": {
"type": "string",
Expand All @@ -26,7 +26,7 @@
},
"email": {
"type": "string",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))"
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))"
},
"firstName": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"email": {
"type": "string",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))"
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))"
},
"usernameInIdp": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"minLength": 3,
"maxLength": 300,
"format": "email",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))"
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))"
},
"usernameInIdp": {
"type": "string",
Expand All @@ -26,7 +26,7 @@
},
"email": {
"type": "string",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))",
"format": "email",
"minLength": 6,
"maxLength": 512
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"email": {
"type": "string",
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,3})))"
"pattern": "^([^.%+!$&*=^|~#%{}]+)[a-zA-Z0-9\\._%+!$&*=^|~#%{}/\\-]+([^.!]+)@([^-.!](([a-zA-Z0-9\\-]+\\.){1,}([a-zA-Z]{2,63})))"
},
"firstName": {
"type": "string",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ describe('UserService', () => {
'email@domain.name',
'email@domain.co.jp',
'firstname-lastname@domain.com',
'firstname-lastname@domain.aridiculouslylongtldfortesting',
];
it.each(validEmails)('should pass when creating users with valid email: %p', async email => {
// BUILD
Expand Down Expand Up @@ -202,6 +203,7 @@ describe('UserService', () => {
'email@domain', // Missing top level domain (.com/.net/.org/etc)
'email@-domain.com', // Leading dash in front of domain is invalid
'email@domain..com', // Multiple dot in the domain portion is invalid
'firstname-lastname@domain.12345678901234567890123456789012345678901234567890123456789012345678901234567890abittoolongtld',
];
it.each(invalidEmails)('should fail when creating users with invalid email: %p', async email => {
// BUILD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ Resources:
exports.handler = (event, context, callback) => {
event.response.autoConfirmUser = true;
// This regex check should be the same as the one in create-user email pattern
const emailRegex = /^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/
const emailRegex = /^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,63})+$/
const { userPoolId, triggerSource, request, userName } = event
const logInfo = { userPoolId, triggerSource, userName,
requestBody: { name: request.name, given_name: request.given_name, family_name: request.family_name, email: request.email } }
Expand Down

0 comments on commit eab8ec9

Please sign in to comment.