0

customData.id用户注册到我的应用程序后,会在本地 MySQL 服务器中分配一个 ID,然后在相应的 Stormpath 帐户中注册相同的 ID 。

这在迁移到 Okta 之前有效(使用 express-stormpath 版本 3.2.0)。迁移和更新到 4.0.0 版后,相同的代码不再起作用,我找不到参考或文档来了解要更改的内容。没有显式错误,但 customData 不会出现在“配置文件”下的新帐户中,并且如果调用结果未定义。

相关postRegistrationHandler

postRegistrationHandler: function(account, req, res, next) {
    account.getCustomData(function(err, data) {
        if (err) {
            return next(err);
        }
        else {
            var newaccount = {
                email: account.email,
                isgestore: isgestore,
                stormpath_href: account.href,
                dataiscrizione: new Date()
            };
            db.query('SELECT * FROM utenti WHERE email = "'+account.email+'";', function(err,check){
                if(err) throw err;
                if(check==''){
                    res.sendStatus(500);
                } else {
                    db.query('UPDATE utenti SET ? WHERE email = "'+account.email+'";', newaccount, function(err,result){
                        if(err) throw err;
                        data.id = check[0].id;
                        data.save();
                        res.redirect('/regRedirect');
                    });
                }
            });
        }
    });
},

从 Stormpath 迁移到 Okta 是成功的,并且 customData 已正确导入。该问题仅出现在新注册的帐户中。

4

1 回答 1

0

我最近自己将一个应用程序从 Stormpath 迁移到 Okta。主要使用 Java SDK,但也使用 express nodejs 库。不能说过渡是无摩擦的。

您可能会想到几件事情可以检查: - 您正在更新“id”字段。这可能是 Okta 中的保留字段。应该是 profile.id 吗?- 看看您是否可以使用 REST API 来更新您的用户。通过直接访问 API 可能更容易找出问题所在。

首先获取您的用户。

curl -X GET \
https://<your okta app>.com/api/v1/users/<user id> \
  -H 'accept: application/json' \
  -H 'authorization: SSWS  <your api token>' \
  -H 'content-type: application/json' 

尝试在配置文件部分设置要更新的属性

  curl -X POST \
  https://<your okta app>.com/api/v1/users/<user id> \
  -H 'accept: application/json' \
  -H 'authorization: SSWS  <your api token>' \
  -H 'content-type: application/json' \
  -d '{
  "profile": {
        "lastName": "johns",
        "secondEmail": null,
        "mobilePhone": null,
        "emailVerificationStatus": "UNKNOWN",
        "email": "chris.johns@domainium.com",
        "stormpathMigrationRecoveryAnswer": "What is the length of a string",
        "login": "chris.johns@domainium.com",
        "firstName": "chris"
    }
}'

OKTA 用户 API 参考: https ://developer.okta.com/docs/api/resources/users.html

于 2017-08-21T07:37:42.227 回答