mailgun连接器回送的用户验证错误:电子邮件存在

时间:2016-03-30 13:28:34

标签: node.js mongodb loopbackjs strongloop mailgun

我参加了示例项目here并添加了loopback-connector-mailgun。我这样配置:

datasources.json中添加了以下内容:

{
    "mailgun": {
        "connector": "loopback-connector-mailgun",
        "apikey": "[my api key here]",
        "domain": "[my domain here]"
    }
}

然后在model-config.json

{
    "Email": {
        "dataSource": "mailgun",
        "public": false
    }
}

当我通过localhost:3000/api/clients中的帖子注册客户端时,验证邮件已成功发送,但服务器未将我重定向到主页,一段时间后(它挂起约30秒)我得到了以下错误:

{"name":"ValidationError","status":422,"message":"The `client` instance is not valid. Details: `email` Email already exists (value: \"a@b.com\") ...

gist中报告了完整堆栈。

我的client.js功能:

Client.afterRemote('create', function(context, client, next) {
    console.log('> client.afterRemote triggered');
    //console.log(typeof client);
    //var auth = dsConfig.emailDs.transports[0].auth;
    var options = {
        type: 'email',
        to: client.email,
        from: "noreply@loopback.com",
        subject: 'Thanks for registering.',
        template: path.resolve(__dirname, '../../server/views/verify.handlebars'),
        redirect: '/verified',
        user: client
    };

    client.verify(options, function(err, response) {
        console.log(err + 'Debug point 1');
        if (err) return next(err);

        console.log('> verification email sent:', response);

        context.res.render('response', {
            title: 'Signed up successfully',
            content: 'Please check your email and click on the verification link ' +
            'before logging in.',
            redirectTo: '/',
            redirectToLinkText: 'Log in'
        });
    });
});

执行永远不会达到Debug Point 1。谢谢!

0 个答案:

没有答案