mayvn
mayvn

Reputation: 191

onBeforeAction: How to Check Email Verified

I'm trying to check the email is verified on the router within an onBeforeAction hook but it's throwing 2 errors. Do you know how to address both?

Error 1:

Exception in callback of async function: .onBeforeAction@http://localhost:3000/lib/router.js?5f85a874ea86a78deb8c19a394c27e00c5a5f753:34:9

Error 2:

Route dispatch never rendered. Did you forget to call this.next() in an onBeforeAction?

The code:

onBeforeAction: function () {
    if (Meteor.user()) {
        var user = Meteor.user();
        if (!user.emails[0].verified) { // line 34
            Router.go('confirmEmail');
        } else if (!user.gamertagScanned) {
            Router.go('confirmGt');
        } else {
            this.next();
        }
    } else {
        this.render('aboutUs');
    }
},

Upvotes: 0

Views: 52

Answers (1)

Michel Floyd
Michel Floyd

Reputation: 20227

You shouldn't be doing a Router.go() from within onBeforeAction - I suspect you want this.render('confirmEmail') and this.render('confirmGt') instead.

Upvotes: 1

Related Questions