Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution to allow for the implementation of two-factor authentication #769

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,9 @@ AT.prototype._init = function() {
}
break;
default:
field.visible = ["signUp"];
if (!field.visible) {
field.visible = ["signUp"];
}
}

// Validation
Expand Down
3 changes: 3 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
38 changes: 24 additions & 14 deletions lib/templates_helpers/at_pwd_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}
}

// -------
Expand Down Expand Up @@ -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("");
});
});
});
}
}

//----------------
Expand Down