diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee index 26c31de84c..bedaf60d79 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee +++ b/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee @@ -3,6 +3,7 @@ User = require("../../models/User").User {db, ObjectId} = require("../../infrastructure/mongojs") crypto = require 'crypto' bcrypt = require 'bcrypt' +EmailHelper = require("../Helpers/EmailHelper") BCRYPT_ROUNDS = Settings?.security?.bcryptRounds or 12 @@ -29,8 +30,9 @@ module.exports = AuthenticationManager = callback null, null validateEmail: (email) -> - if !email?.length - return { message: 'email not set' } + parsed = EmailHelper.parseEmail(email) + if !parsed? + return { message: 'email not valid' } return null validatePassword: (password) -> @@ -45,7 +47,7 @@ module.exports = AuthenticationManager = return null setUserPassword: (user_id, password, callback = (error) ->) -> - validation = validatePassword(password) + validation = @validatePassword(password) return callback(validation.message) if validation? bcrypt.genSalt BCRYPT_ROUNDS, (error, salt) -> diff --git a/services/web/app/coffee/Features/User/UserRegistrationHandler.coffee b/services/web/app/coffee/Features/User/UserRegistrationHandler.coffee index 1fa1dc0d79..52d731c4bc 100644 --- a/services/web/app/coffee/Features/User/UserRegistrationHandler.coffee +++ b/services/web/app/coffee/Features/User/UserRegistrationHandler.coffee @@ -14,9 +14,8 @@ EmailHelper = require("../Helpers/EmailHelper") module.exports = UserRegistrationHandler = _registrationRequestIsValid : (body, callback)-> - email = EmailHelper.parseEmail(body.email) or '' - invalidEmail = AuthenticationManager.validateEmail(email) - invalidPassword = AuthenticationManager.validatePassword(body.password) + invalidEmail = AuthenticationManager.validateEmail(body.email or '') + invalidPassword = AuthenticationManager.validatePassword(body.password or '') if invalidEmail? or invalidPassword? return false else