fuzzybabybunny
fuzzybabybunny

Reputation: 5254

Run a function after user has verified email in Meteor using ian:accounts-ui-bootstrap-3?

I've got ian:accounts-ui-bootstrap-3 installed. When the user has verified their email, I want Meteor to create them as a Stripe Customer.

/client/global_client_functions.js

Accounts.onEmailVerificationLink(function(){
    console.log("verification link clicked!");
    alert(Meteor.user()._id);
    Meteor.call("createStripeCustomer", Meteor.user()._id)
});

Meteor.call("createStripeCustomer", Meteor.user()._id) works fine and dandy when I pass in a userId.

But Accounts.onEmailVerificationLink never seems to get called and I also don't get the error "onEmailVerificationLink can only be called once".

Am I using Accounts.onEmailVerificationLink correctly? I don't want to roll my own account ui, so I'd like to stick with using the accounts-ui package.

Upvotes: 0

Views: 181

Answers (1)

Sasikanth
Sasikanth

Reputation: 3043

Assuming that you're using Iron router

this is the default link that meteor generates

this.route('verify-emailHash',{
    controller: 'AccountController',
    path: '/#/verify-email/:token',
    action: 'verifyEmail'
})

//I changed my verification link like below
this.route('verify-email',{
    controller: 'AccountController',
    path: '/verify-email/:token',
    action: 'verifyEmail'
})

AccountController = RouteController.extend({
    verifyEmail: function () {
        Accounts.verifyEmail(this.params.token, function () {
            toastr.success("Email verified");
            alert(Meteor.user()._id);
            Meteor.call("createStripeCustomer", Meteor.user()._id)
        });
    }
});

Upvotes: 1

Related Questions