Merge pull request #71 from christroutner/unstable

fix(email validation): Removing email validation that was failing for some TLDs
This commit is contained in:
Chris Troutner
2020-06-08 07:43:28 -07:00
committed by GitHub
2 changed files with 29 additions and 27 deletions
+6 -4
View File
@@ -59,10 +59,12 @@ class UserController {
throw new Error("Property 'email' must be a string!")
}
const isEmail = await _this.validateEmail(user.email)
if (!isEmail) {
throw new Error("Property 'email' must be email format!")
}
// This validation is not permissive to different TLDs like this one:
// someone@somewhere.link. Removing it until it can be updated.
// const isEmail = await _this.validateEmail(user.email)
// if (!isEmail) {
// throw new Error("Property 'email' must be email format!")
// }
if (!user.password || typeof user.password !== 'string') {
throw new Error("Property 'password' must be a string!")
+23 -23
View File
@@ -81,29 +81,29 @@ describe('Users', () => {
}
})
it('should reject signup if email property provided in wrong format', async () => {
try {
const options = {
method: 'POST',
url: `${LOCALHOST}/users`,
data: {
user: {
email: 'badEmailFormat',
password: 'test'
}
}
}
await axios(options)
assert(false, 'Unexpected result')
} catch (err) {
assert.equal(err.response.status, 422)
assert.include(
err.response.data,
"Property 'email' must be email format"
)
}
})
// it('should reject signup if email property provided in wrong format', async () => {
// try {
// const options = {
// method: 'POST',
// url: `${LOCALHOST}/users`,
// data: {
// user: {
// email: 'badEmailFormat',
// password: 'test'
// }
// }
// }
// await axios(options)
//
// assert(false, 'Unexpected result')
// } catch (err) {
// assert.equal(err.response.status, 422)
// assert.include(
// err.response.data,
// "Property 'email' must be email format"
// )
// }
// })
it('should reject signup if no password property is provided', async () => {
try {