From a8d1b560d048f2e1953b8e63744b0b7799cc5d17 Mon Sep 17 00:00:00 2001 From: Francis Poirier Date: Fri, 12 Dec 2014 15:57:10 -0500 Subject: [PATCH 1/5] Added onSubmit Hook --- lib/core.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/core.js b/lib/core.js index f6e2da6..2ad97ab 100644 --- a/lib/core.js +++ b/lib/core.js @@ -109,12 +109,15 @@ CONFIG_PAT = { homeRoutePath: Match.Optional(String), redirectTimeout: Match.Optional(Number), + // Hooks + onSubmitHook: Match.Optional(Function), + texts: Match.Optional(TEXTS_PAT), }; FIELD_SUB_PAT = { - "default": Match.Optional(String), + default: Match.Optional(String), changePwd: Match.Optional(String), enrollAccount: Match.Optional(String), forgotPwd: Match.Optional(String), @@ -268,6 +271,9 @@ AT.prototype.options = { // Redirects homeRoutePath: "/", redirectTimeout: 2000, // 2 seconds + + // Hooks + onSubmitHook: undefined, }; AT.prototype.SPECIAL_FIELDS = [ @@ -294,12 +300,12 @@ AT.prototype._fields = [ required: true, minLength: 6, displayName: { - "default": "password", + default: "password", changePwd: "newPassword", resetPwd: "newPassword", }, placeholder: { - "default": "password", + default: "password", changePwd: "newPassword", resetPwd: "newPassword", }, From 7db0feaffb1d015d53b6384f13e070ea4221efd0 Mon Sep 17 00:00:00 2001 From: Francis Poirier Date: Fri, 12 Dec 2014 15:57:27 -0500 Subject: [PATCH 2/5] Added onSubmit Hook --- lib/client.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/client.js b/lib/client.js index 80cb3f0..3cbfcff 100644 --- a/lib/client.js +++ b/lib/client.js @@ -237,12 +237,12 @@ AT.prototype._init = function() { var pwdAgain = _.clone(this.getField("password")); pwdAgain._id = "password_again"; pwdAgain.displayName = { - "default": "passwordAgain", + default: "passwordAgain", changePwd: "newPasswordAgain", resetPwd: "newPasswordAgain", }; pwdAgain.placeholder = { - "default": "passwordAgain", + default: "passwordAgain", changePwd: "newPasswordAgain", resetPwd: "newPasswordAgain", }; @@ -468,6 +468,11 @@ AT.prototype.postSubmitRedirect = function(route){ }; AT.prototype.submitCallback = function(error, state, onSuccess){ + + var onSubmitHook = AccountsTemplates.options.onSubmitHook; + if(onSubmitHook) + onSubmitHook(error, state); + if (error) { if(_.isObject(error.details)) // If error.details is an object, we may try to set fields errors from it @@ -481,8 +486,10 @@ AT.prototype.submitCallback = function(error, state, onSuccess){ AccountsTemplates.setDisabled(false); } else{ + //if the onSuccess callback return false it means that we don't want any redirection if (onSuccess) - onSuccess(); + onSuccess() + if (_.contains(["enrollAccount", "forgotPwd", "resetPwd", "verifyEmail"], state)){ var redirectTimeout = AccountsTemplates.options.redirectTimeout; if (redirectTimeout > 0) From 6aa9d8c473c0d6a54d15916cea3d9e064a0af318 Mon Sep 17 00:00:00 2001 From: Francis Poirier Date: Fri, 12 Dec 2014 16:18:07 -0500 Subject: [PATCH 3/5] Fix default key change --- lib/client.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/client.js b/lib/client.js index 3cbfcff..0f6b224 100644 --- a/lib/client.js +++ b/lib/client.js @@ -237,12 +237,12 @@ AT.prototype._init = function() { var pwdAgain = _.clone(this.getField("password")); pwdAgain._id = "password_again"; pwdAgain.displayName = { - default: "passwordAgain", + "default": "passwordAgain", changePwd: "newPasswordAgain", resetPwd: "newPasswordAgain", }; pwdAgain.placeholder = { - default: "passwordAgain", + "default": "passwordAgain", changePwd: "newPasswordAgain", resetPwd: "newPasswordAgain", }; From f189c5174d0ad6ffbac9cabaf9a363b5af199805 Mon Sep 17 00:00:00 2001 From: Francis Poirier Date: Fri, 12 Dec 2014 17:16:50 -0500 Subject: [PATCH 4/5] Removed old comment --- lib/client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/client.js b/lib/client.js index 0f6b224..b0de6f2 100644 --- a/lib/client.js +++ b/lib/client.js @@ -486,7 +486,6 @@ AT.prototype.submitCallback = function(error, state, onSuccess){ AccountsTemplates.setDisabled(false); } else{ - //if the onSuccess callback return false it means that we don't want any redirection if (onSuccess) onSuccess() From 81dcd42d33bf48e6832e16b47e7fb64d113185b9 Mon Sep 17 00:00:00 2001 From: Francis Poirier Date: Fri, 12 Dec 2014 17:18:27 -0500 Subject: [PATCH 5/5] Fix default key change --- lib/core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core.js b/lib/core.js index 2ad97ab..57aff4f 100644 --- a/lib/core.js +++ b/lib/core.js @@ -117,7 +117,7 @@ CONFIG_PAT = { FIELD_SUB_PAT = { - default: Match.Optional(String), + "default": Match.Optional(String), changePwd: Match.Optional(String), enrollAccount: Match.Optional(String), forgotPwd: Match.Optional(String), @@ -300,12 +300,12 @@ AT.prototype._fields = [ required: true, minLength: 6, displayName: { - default: "password", + "default": "password", changePwd: "newPassword", resetPwd: "newPassword", }, placeholder: { - default: "password", + "default": "password", changePwd: "newPassword", resetPwd: "newPassword", },