diff --git a/client/entry.coffee b/client/entry.coffee index fc1436f8..bd3dce5d 100644 --- a/client/entry.coffee +++ b/client/entry.coffee @@ -9,6 +9,7 @@ AccountsEntry = entrySignUp: '/sign-up' extraSignUpFields: [] showOtherLoginServices: true + requirePasswordConfirmation: false isStringEmail: (email) -> emailPattern = /^([\w.-]+)@([\w.-]+)\.([a-zA-Z.]{2,6})$/i diff --git a/client/helpers.coffee b/client/helpers.coffee index fb084259..7c57b62d 100644 --- a/client/helpers.coffee +++ b/client/helpers.coffee @@ -33,6 +33,9 @@ UI.registerHelper 'loginServices', -> UI.registerHelper 'showSignupCode', -> AccountsEntry.settings.showSignupCode is true +UI.registerHelper 'showPasswordConfirmation', -> + AccountsEntry.settings.requirePasswordConfirmation is true + UI.registerHelper 'passwordLoginService', -> !!Package['accounts-password'] diff --git a/client/t9n/english.coffee b/client/t9n/english.coffee index 6181f772..cc76550a 100644 --- a/client/t9n/english.coffee +++ b/client/t9n/english.coffee @@ -11,6 +11,7 @@ en = resetYourPassword: "Reset your password" updateYourPassword: "Update your password" password: "Password" + confirmPassword: "Confirm Password" usernameOrEmail: "Username or email" email: "Email" ifYouAlreadyHaveAnAccount: "If you already have an account" @@ -33,6 +34,7 @@ en = minChar: "7 character minimum password." pwOneLetter: "Password requires 1 letter." pwOneDigit: "Password must have at least one digit." + pwNoMatch: "Passwords must match." usernameRequired: "Username is required." emailRequired: "Email is required." signupCodeRequired: "Registration code is required." diff --git a/client/views/resetPassword/resetPassword.coffee b/client/views/resetPassword/resetPassword.coffee index d957dfd2..9c719f2c 100644 --- a/client/views/resetPassword/resetPassword.coffee +++ b/client/views/resetPassword/resetPassword.coffee @@ -8,11 +8,18 @@ Template.entryResetPassword.events 'submit #resetPassword': (event) -> event.preventDefault() - password = $('input[type="password"]').val() + password = $('input[name="new-password"]').val() passwordErrors = do (password)-> errMsg = [] msg = false + + if AccountsEntry.settings.requirePasswordConfirmation + password2 = $('input[name="new-password2"]').val() + + if password isnt password2 + errMsg.push t9n("error.pwNoMatch") + if password.length < 7 errMsg.push t9n("error.minChar") if password.search(/[a-z]/i) < 0 diff --git a/client/views/resetPassword/resetPassword.html b/client/views/resetPassword/resetPassword.html index b9dfeb0a..35d26889 100644 --- a/client/views/resetPassword/resetPassword.html +++ b/client/views/resetPassword/resetPassword.html @@ -13,8 +13,17 @@