流星账号验证邮箱

Meteor accounts verifyEmail

我正在尝试使用帐户密码包进行电子邮件验证,但是我遇到了一个奇怪的问题。

似乎电子邮件验证中的 # URL 引起了问题。验证电子邮件 URL 通常如下所示:http://localhost:3000/#/verify-email/cnaTqQSCgYAksIsFo5FgmV94NHwrfaM2g5GvdZDUMlN

当我点击它时,似乎什么也没有发生;它只是重定向到 localhost:3000/#

然而,当我删除 # (http://localhost:3000/verify-email/cnaTqQSCgYAksIsFo5FgmV94NHwrfaM2g5GvdZDUMlN) 时,这似乎完美无缺。

URL (http://localhost:3000/#/verify-email/cnaTqQSCgYAksIsFo5FgmV94NHwrfaM2g5GvdZDUMlN) 来自 Meteor,所以它不是我创造的。

这是我的路由和控制器(使用 iron-router)

Router.route('/verify-email/:_token', {
    controller : 'AccountController',
    action : 'verifyEmail'
});

AccountController = RouteController.extend({
    fastRender: true,
    data: function () {},
    onBeforeAction: function () {
        this.render('Loading');
        this.next();
    },

    verifyEmail: function() {
        var verificationToken = this.params._token;
        console.log(verificationToken);
        Accounts.verifyEmail(verificationToken,  function(error) {
           if (error) {
               console.log(error);
           } else {
               Router.go('/');
           }
        });

    }
});

感谢任何帮助。

冲突可能与帐户密码包以及 iron:router 相关,如下所述:

...add a server file that overrides the urls with # paths that Meteor creates, so that the Iron-Router can work:

(function () {
    "use strict";

    Accounts.urls.resetPassword = function (token) {
        return Meteor.absoluteUrl('reset-password/' + token);
    };

    Accounts.urls.verifyEmail = function (token) {
        return Meteor.absoluteUrl('verify-email/' + token);
    };

    Accounts.urls.enrollAccount = function (token) {
        return Meteor.absoluteUrl('enroll-account/' + token);
    };

})();

希望它能为您指明正确的方向。