diff --git a/lib/client.js b/lib/client.js index 31c9db7..90331fb 100644 --- a/lib/client.js +++ b/lib/client.js @@ -280,7 +280,9 @@ AT.prototype._init = function() { } break; default: - field.visible = ["signUp"]; + if (!field.visible) { + field.visible = ["signUp"]; + } } // Validation diff --git a/lib/core.js b/lib/core.js index 1c7bc07..a78ab4e 100644 --- a/lib/core.js +++ b/lib/core.js @@ -99,6 +99,8 @@ CONFIG_PAT = { overrideLoginErrors: Match.Optional(Boolean), sendVerificationEmail: Match.Optional(Boolean), socialLoginStyle: Match.Optional(Match.OneOf("popup", "redirect")), + loginFunc: Match.Optional(Function), + resetPasswordFunc: Match.Optional(Function), // Appearance defaultLayout: Match.Optional(String), @@ -170,6 +172,7 @@ FIELD_PAT = { re: Match.Optional(RegExp), func: Match.Optional(Match.Where(_.isFunction)), errStr: Match.Optional(String), + visible: Match.Optional([String]), // Client-side Validation continuousValidation: Match.Optional(Boolean), diff --git a/lib/templates_helpers/at_pwd_form.js b/lib/templates_helpers/at_pwd_form.js index 2f8d53c..f93a812 100644 --- a/lib/templates_helpers/at_pwd_form.js +++ b/lib/templates_helpers/at_pwd_form.js @@ -169,10 +169,14 @@ AT.prototype.atPwdFormEvents = { return; } - - return Meteor.loginWithPassword(loginSelector, password, function(error) { + if (AccountsTemplates.options.loginFunc) { + return AccountsTemplates.options.loginFunc(loginSelector, password, formData); + } + else { + return Meteor.loginWithPassword(loginSelector, password, function (error) { AccountsTemplates.submitCallback(error, state); - }); + }); + } } // ------- @@ -285,18 +289,24 @@ AT.prototype.atPwdFormEvents = { //-------------------------------- if (state === "resetPwd" || state === "enrollAccount") { var paramToken = AccountsTemplates.getparamToken(); - return Accounts.resetPassword(paramToken, password, function(error) { - AccountsTemplates.submitCallback(error, state, function(){ - var pwd_field_id; - if (state === "resetPwd") - AccountsTemplates.state.form.set("result", AccountsTemplates.texts.info.pwdReset); - else // Enroll Account - AccountsTemplates.state.form.set("result", AccountsTemplates.texts.info.pwdSet); - t.$("#at-field-password").val(""); - if (AccountsTemplates.options.confirmPassword) - t.$("#at-field-password_again").val(""); + + if (state === "resetPwd" && AccountsTemplates.options.resetPasswordFunc) { + return AccountsTemplates.options.resetPasswordFunc(paramToken, password, formData); + } + else { + return Accounts.resetPassword(paramToken, password, function(error) { + AccountsTemplates.submitCallback(error, state, function(){ + var pwd_field_id; + if (state === "resetPwd") + AccountsTemplates.state.form.set("result", AccountsTemplates.texts.info.pwdReset); + else // Enroll Account + AccountsTemplates.state.form.set("result", AccountsTemplates.texts.info.pwdSet); + t.$("#at-field-password").val(""); + if (AccountsTemplates.options.confirmPassword) + t.$("#at-field-password_again").val(""); + }); }); - }); + } } //----------------