Auth0用户注册后Webtask保存到mongodb

时间:2017-04-25 19:10:33

标签: mongodb auth0

我想将Auth0用于我的项目,因为我想使用他们的服务来保存用户和&密码,我希望能够将至少用户数据导出到我的mongodb数据库。

Auth0有一些用户注册挂钩,一旦用户成功注册就会被触发,所以我想执行我的脚本将该用户保存到我在mlab上托管的mongodb数据库。

现在,我以前从未使用过Webtask,但我没有得到它......有人可以帮我实现目标吗?

干杯

编辑:这就是我现在使用的:

var mongoose = require("mongoose");
mongoose.connect("mongodb://username:password@ds115131.mlab.com:15131/dbname");

var UserrSchema = new mongoose.Schema({
  username: String,
  email: String,
})

module.exports = mongoose.model("Userr", UserrSchema);

module.exports = function (user, context, cb) {
  var username = user.username;
  var email = user.email;

  var newUserr = {
    username,
    email,
  };
  Userr.create(newUserr, function (err, newlyCreated) {
    if(err) return (err);
    nnewlyCreated.save();
  });
};

使用此脚本时出现此错误:

{
  "message": "Unauthorized extensibility point",
  "statusCode": 500,
  "stack": "Error: Unauthorized extensibility point\n    at Object.is_authorized (/data/sandbox/node_modules/auth0-ext-compilers/lib/authorization.js:15:23)\n    at userRegistrationHandler (/data/sandbox/node_modules/auth0-ext-compilers/lib/compilers/user-registration.js:9:18)\n    at /data/sandbox/node_modules/auth0-ext-compilers/lib/adapter.js:90:20\n    at finish (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/lib/index.js:351:20)\n    at wrapped (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/node_modules/hoek/lib/index.js:871:20)\n    at onReaderFinish (/data/sandbox/node_modules/auth0-ext-compilers/node_modules/wreck/lib/index.js:415:16)\n    at g (events.js:260:16)\n    at emitNone (events.js:72:20)\n    at emit (events.js:166:7)\n    at finishMaybe (_stream_writable.js:481:14)\n    at endWritable (_stream_writable.js:491:3)\n    at Writable.end (_stream_writable.js:456:5)\n    at IncomingMessage.onend (_stream_readable.js:498:10)\n    at IncomingMessage.g (events.js:260:16)\n    at emitNone (events.js:72:20)\n    at IncomingMessage.emit (events.js:166:7)"
}

0 个答案:

没有答案