Search code examples
meteormeteor-accountsflow-router

Using FlowRouter with onResetPasswordLink, onEnrollmentLink and onEmailVerificationLink


I am reluctantly implementing my own user accounts system because Meteor uses bcrypt to store encrypted passwords and my Dovecot/Postfix email system running on an Ubuntu instance uses SHA512. The Debian/Ubuntu folks have chosen to not implement bcrypt in their Linux distribution necessitating this rather painful exercise. This requires me to grab the unencrypted password in my own users accounts hack to generate and save an SHA512 version which I subsequently use to provision email service for my members.

I implemented the solution offered by @bgmaster and @stubailo below but it doesn't seem to work with FlowRouter. As @bgmaster pointed, he was not able to get it to work with iron:router. In my case, the onEnrollmentLink callback never gets fired apparently because FlowRouter gains control before the the function can execute. If I drop the 'enroll-account/token' route, FlowRouter complains about not having a route.

Before I rip out FlowRouter, has anybody been able to implement their own user accounts system using core Meteor accounts and FlowRouter? Better yet, is there any way to grab the unencrypted password during the standard accounts workflow? I would much prefer to use the built-in 'accounts-ui' package or even 'useraccounts'.

Thanks!

Using onResetPasswordLink, onEnrollmentLink, and onEmailVerificationLink methods properly in Meteor


Solution

  • You'll have to roll your own UI then use Accounts.createUser()

    I strongly recommend you compute the SHA512 hash on the client before you call Accounts.createUser() and pass the hash in as part of the profile object so that it ends up being saved with the account.

    The email verification link shouldn't matter since the password isn't captured at that point but you'll also need to create your own password reset UI.