Search code examples
meteormeteor-useraccounts

Add custom field on signin form


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?


Solution

  • The answer i managed to implement was to change the pattern with a different approach, using directly Meteor API:

    1. Set a special field on user collection: tokenverified: false
    2. Add Meteor.onLogin (called each time you login or refresh manually the page) and Meteor.onLogout callback to set this field to false
    3. Create a template verify2FA to deal with token and set tokenverified: true
    4. Create an iron-router plugin ensure2FA that will check this token and redirect to the verify2FA template.