hapi-auth-cookie:读取 cookie 以访问锁定内容时抛出错误

hapi-auth-cookie: throws error when reading cookies to access locked content

我已经使用 hapi-auth-cookie 来保存 cookie 和创建会话。 某些部分被锁定,用户未经身份验证不得访问。 当用户未登录时,他被成功重定向到登录路由。身份验证后,当用户再次单击相同的 link 时,它很可能在处理 cookie.This 会话注册时抛出错误:

plugin.auth.strategy('session', 'cookie', {
    password: 'hapissajafdhafdjahyfjkdgsyjasfydukfeyafdheavjdfaejmyfdja',
    cookie: 'sid-cuboid',
    redirectTo: '/',
    isSecure: false,
    validateFunc: function(request, session) {
        var cached = cache.get(session.sid);
        var out = {
            valid: !!cached
        };

        if (out.valid) {
            out.credentials = cached.account;
        }

        return out;
    }
});

这是我的路线:

plugin.route({
        method: 'GET',
        path: '/edit/{courseName}/{testNo}/{plunkId}',
        config: {
            auth: {
                strategy: 'session'

            },
            plugins: {
                'hapi-auth-cookie': {
                    redirectTo: '/'
                }
            }
        },
        handler: function(request, reply) {
            var server = this.config.server;
            var param = request.params;
            var courseName = request.params.courseName;
            var context = {
                "url": {
                    "run": ""
                }
            };

            reply.view("editor", context);

        }

    });

这是我收到的错误:

Debug: internal, implementation, error 
    TypeError: Uncaught error: Cannot read property 'apply' of undefined
    at bound (domain.js:280:13)
    at runBound (domain.js:293:12)
    at /home/satnam-sandhu/Workstation/cuboid.io/node_modules/glue/node_modules/hoek/lib/index.js:858:22
    at doNTCallback0 (node.js:419:9)
    at process._tickDomainCallback (node.js:389:13)

注意:我正在使用 nodejs@4.2.2 和 hapi-auth-cookie@6.1.1

上述问题已通过删除 validateFunc 得到解决。错误原因还不清楚。