Using meteor useraccounts package, I would like to add a custom field in signIn form (named token) to enable 2fa authentication.
Unfortunatly on AccountTemplates.addField only work with signUp form, as far as I have worked on it.
Any hint?
Using meteor useraccounts package, I would like to add a custom field in signIn form (named token) to enable 2fa authentication.
Unfortunatly on AccountTemplates.addField only work with signUp form, as far as I have worked on it.
Any hint?
On
The accounts package has an Accounts.onLogin function that you can use to call a method and update the user account.
Accounts.onLogin(function(user) {
Meteor.call('setToken', user)
})
and then
Meteor.methods({
setToken: function(user) {
// Do some clever check
Meteor.users.update(/* Set your token */);
},
});
The advantage of using a method is that you can do some server-side check to ensure your token has not been hacked.
The answer i managed to implement was to change the pattern with a different approach, using directly Meteor API:
tokenverified: falseMeteor.onLogin(called each time you login or refresh manually the page) andMeteor.onLogoutcallback to set this field to falseverify2FAto deal with token and settokenverified: trueensure2FAthat will check this token and redirect to theverify2FAtemplate.