Explorar el Código

Fix ordering of boolean check to be more readable

Alasdair Smith hace 8 años
padre
commit
e129172553

+ 4 - 4
services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee

@@ -39,11 +39,11 @@ module.exports = AuthenticationManager =
 		if !password?
 			return { message: 'password not set' }
 		if (Settings.passwordStrengthOptions?.length?.max? and
-				Settings.passwordStrengthOptions?.length?.max < password.length)
-			return { message: 'password is too short' }
-		if (Settings.passwordStrengthOptions?.length?.min? and
-				Settings.passwordStrengthOptions?.length?.min > password.length)
+				password.length > Settings.passwordStrengthOptions?.length?.max)
 			return { message: "password is too long" }
+		if (Settings.passwordStrengthOptions?.length?.min? and
+				password.length < Settings.passwordStrengthOptions?.length?.min)
+			return { message: 'password is too short' }
 		return null
 
 	setUserPassword: (user_id, password, callback = (error) ->) ->

+ 2 - 0
services/web/test/unit/coffee/Authentication/AuthenticationManagerTests.coffee

@@ -135,6 +135,8 @@ describe "AuthenticationManager", ->
 
 			it "should return validation error object if too long", ->
 				result = @AuthenticationManager.validatePassword 'dsdsadsadsadsadsadkjsadjsadjsadljs'
+				expect(result).to.not.equal null
+				expect(result.message).to.equal 'password is too long'
 
 	describe "setUserPassword", ->
 		beforeEach ->