From e129172553231a8bd9b310ccb09301aff09b3724 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Mon, 8 Oct 2018 11:25:24 +0100 Subject: [PATCH] Fix ordering of boolean check to be more readable --- .../Features/Authentication/AuthenticationManager.coffee | 8 ++++---- .../Authentication/AuthenticationManagerTests.coffee | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee b/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee index 64da009387..f381735969 100644 --- a/services/web/app/coffee/Features/Authentication/AuthenticationManager.coffee +++ b/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) ->) -> diff --git a/services/web/test/unit/coffee/Authentication/AuthenticationManagerTests.coffee b/services/web/test/unit/coffee/Authentication/AuthenticationManagerTests.coffee index be2ed44979..39880b112e 100644 --- a/services/web/test/unit/coffee/Authentication/AuthenticationManagerTests.coffee +++ b/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 ->