How to use the done callback in the onEnrollmentLink() function?


I want to serve a specific page to users who clicked on the enrollment link. So I figured the best way to do this is via Accounts.onEnrollmentLink(). But I am apparently not using this function correctly because the flow stalls and can’t seem to find a good solution.

The problem seems to be this done callback. The docs state:

done: A function to call when the enrollment UI flow is complete. The normal login process is suspended until this function is called, so that user A can be enrolled even if user B was logged in.

Right… So, in real terms, what does this mean? Is it asking me to call this function inside this onEnrollmentLink function or do I have to take done, remember it somehow, and then call it after whatever template I have is rendered?

It seems like this should be very simple but whenever I try to use this callback to enroll user B the flow is stalled and user A remains logged in whilst user B is not enrolled.



My question was a bit verbose. Actually all I need is an example of how this function should be used.

Same question posted at SO here.