用户注册到我的应用程序后,在本地MySQL服务器中分配一个ID,然后在相应的Stormpath帐户中将相同的ID注册为customData.id
。
这在迁移到Okta之前有效(使用express-stormpath版本3.2.0)。迁移和更新到4.0.0版之后,相同的代码不再起作用,我找不到引用或文档来知道要更改的内容。没有明确的错误,但customData不会出现在“profile”下的新帐户中,如果调用则结果未定义。
相关的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。该问题仅适用于新注册的帐户。
答案 0 :(得分: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