diff options
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | templates/strings.js | 5 | ||||
-rw-r--r-- | www/js/config.js-example | 10 | ||||
-rw-r--r-- | www/js/strings.en.js | 5 | ||||
-rw-r--r-- | www/js/strings.es.js | 5 | ||||
-rw-r--r-- | www/js/views/login.js | 2 | ||||
-rw-r--r-- | www/js/views/submit.js | 7 |
7 files changed, 30 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index cb1c960..1f47795 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,5 +12,6 @@ - Allow mailto: links to be followed. #263 - Stop keyboard obscuring report details text field. #222 - Development improvements - - CONFIG.SKIP_CONFIRM_REPORT flag to skip confirmation screen + - CONFIG.SKIP_CONFIRM_REPORT flag to skip confirmation screen. - Ensure compatibility with latest Cordova versions. + - CONFIG.PASSWORD_MIN_LENGTH key to validate user password. diff --git a/templates/strings.js b/templates/strings.js index 63e3bed..f43eef3 100644 --- a/templates/strings.js +++ b/templates/strings.js @@ -17,7 +17,10 @@ required: '[% loc('Please enter your email') %]', email: '[% loc('Please enter a valid email') %]' }, - password: '[% loc('Please enter a password') %]' + password: { + required: '[% loc('Please enter a password') %]', + short: '[% loc('Please enter a password at least %d characters long') %]' + } }, strings: { next: '[% loc('Next') %]', diff --git a/www/js/config.js-example b/www/js/config.js-example index 6be0250..66e0ed8 100644 --- a/www/js/config.js-example +++ b/www/js/config.js-example @@ -69,7 +69,15 @@ var CONFIG = { // If the user is logged in and this setting is true, the 'Your details' // page is skipped and the report is sent immediately after the report // details have been entered. - SKIP_CONFIRM_REPORT: false + SKIP_CONFIRM_REPORT: false, + + // You can optionally enforce a minimum password length if the user is + // registering an account when submitting a report. This should match the + // same minimum length required by your FixMyStreet server. + // Set this to 0 if you wish to disable this check. NB: If the check is + // active on the server the user's password may still be rejected if it's + // too short. + PASSWORD_MIN_LENGTH: 6 }; diff --git a/www/js/strings.en.js b/www/js/strings.en.js index 1dabd30..bf67b14 100644 --- a/www/js/strings.en.js +++ b/www/js/strings.en.js @@ -17,7 +17,10 @@ required: 'Please enter your email', email: 'Please enter a valid email' }, - password: 'Please enter a password' + password: { + required: 'Please enter a password', + short: 'Please enter a password at least %d characters long' + } }, strings: { next: 'Next', diff --git a/www/js/strings.es.js b/www/js/strings.es.js index 9c8b950..5b2481b 100644 --- a/www/js/strings.es.js +++ b/www/js/strings.es.js @@ -17,7 +17,10 @@ required: 'Por favor, introduzca su email', email: 'Por favor, introduzca un email válido' }, - password: 'Por favor, introduzca la contraseña' + password: { + required: 'Por favor, introduzca la contraseña', + short: 'Please enter a password at least %d characters long' + } }, strings: { next: 'Siguiente', diff --git a/www/js/views/login.js b/www/js/views/login.js index 93a9a5b..9225c18 100644 --- a/www/js/views/login.js +++ b/www/js/views/login.js @@ -78,7 +78,7 @@ if ( !$('#form_password').val() ) { isValid = 0; - this.validationError('form_password', FMS.validationStrings.password ); + this.validationError('form_password', FMS.validationStrings.password.required); } var email = $('#form_email').val(); diff --git a/www/js/views/submit.js b/www/js/views/submit.js index f24f21c..99f2d9b 100644 --- a/www/js/views/submit.js +++ b/www/js/views/submit.js @@ -340,11 +340,16 @@ }, validate: function() { + this.clearValidationErrors(); var isValid = 1; if ( !$('#form_password').val() ) { isValid = 0; - this.validationError('form_password', FMS.validationStrings.password ); + this.validationError('form_password', FMS.validationStrings.password.required ); + } else if ( CONFIG.PASSWORD_MIN_LENGTH && $('#form_password').val().length < CONFIG.PASSWORD_MIN_LENGTH ) { + isValid = 0; + var msg = FMS.validationStrings.password.short.replace('%d', CONFIG.PASSWORD_MIN_LENGTH); + this.validationError('form_password', msg); } if ($('#form_name').val() && !this.validateUserTitle()) { |