Stormpath用法-是否需要?

时间:2019-01-13 13:50:46

标签: node.js express heroku twilio twilio-api

我有一个简单的应用程序(于2016年开发),可与twilio API交互(发送/接收消息)。以前的开发人员使用stormpath进行身份验证。 Stormpath于Okta 2017出售,此后该系统已关闭。现在,我需要再次使该应用程序联机。

我不确定是否需要继续使用类似于风暴路径的服务,因为我仅打算创建几个供亲朋好友使用的帐户。我不打算使用它并将其集成到另一个系统中。

因此,我正在寻找最便宜的解决方案以使其正常运行: +完全删除(不确定是否可行) +将其迁移到okta +将其迁移到auth0

能给我一些想法吗?

这是我所做的 -从github提取代码 -在Heroku上创建新应用 -将代码推送到heroku -为应用程序安装Redis -设置Twilio的环境变量(TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN)以及REDISCLOUD_URL,EXPRESS_SECRET

//stormpath init
app.use(stormpath.init(app, {
  website: true,
  api: true,
  expand: {
    apiKeys: true,
    customData: true
  },
  web: {
    login: {
      nextUri: '/private/dashboard'
    },
    logout: {
      nextUri: '/'
    }
  },
  postRegistrationHandler: function(account, req, res, next) {
    async.parallel([
      // Set the user's default settings.
      function(cb) {        
        account.customData.credits = 0;   
        cb();
      },
      // Create an API key for this user.
      function(cb) {
        account.createApiKey(function(err, key) {
          if (err) return cb(err);
          cb();
        });
      },
      //create subaccount on twilio
      function(cb) {
        client.accounts.create({
          friendlyName: account.email
        }, function(err, twilioAccount) {
          if(err) {
            console.log('cannot create subaccount on twilio');
            return cb(err);
          }
          account.customData.accountSid = twilioAccount.sid;
          account.customData.save(function(error) {
            if(error) return cb(error);

            cb();
          })          
        });
      }
    ], function(err) {
      if (err) return next(err);
      next();
    });
  },
  postLoginHandler: function(account, req, res, next) {
    initPhoneNumbers(req, res, next);
  }
}));

这是应用程序的日志文件:https://pastebin.com/75aetfZD

0 个答案:

没有答案
相关问题