The Stormpath documentation 은 PostRegistrationHandler에서 사용자 속성을 수정하는 것에 대해 아무 것도 말하지 않고 이것을 수행 할 수 있어야합니다.Express.js Stormpath PostRegistrationHandler
사용자를 생성 한 후 속성으로 임의의 문자열을 지정하고 싶습니다. 이 무작위 문자열은 내 별도의 Mongo Database에 대한 열쇠가 될 것입니다. 내 app.js, 나는이 :
app.use(stormpath.init(app, {
postRegistrationHandler: function(account, res, next) {
// theoretically, this will give a user object a new property, 'mongo_id'
// which will be used to retrieve user info out of MONGOOOO
account.customData["mongo_id"] = "54aabc1c79f3e058eedcd2a7"; // <- this is the thing I'm trying to add
console.log("RESPNSE:\n"+res);
account.save(); // I know I'm using 'account', instead of user, but the documentation uses account. I don't know how to do this any other way
next();
console.log('User:\n', account, '\njust registered!');
},
apiKeyId: '~/.stormpath.apiKey.properties',
//apiKeySecret: 'xxx',
application: ~removed~,
secretKey: ~removed~,
redirectUrl: '/dashboard',
enableAutoLogin: true
}));
내 CONSOLE.LOG 라인에 mongo_id 속성으로 CUSTOMDATA를 인쇄 않습니다 방법을 모르겠어요. 나중에 req.user.customData [ 'mongo_id']를 사용하여 액세스하려고하면 그곳에 없습니다. 계정과 req.user는 서로 달라야합니다. 사용자를 저장하려면 어떻게해야합니까?
질문 : 당신이 라이브러리의 'expandCustomData'옵션을 사용하고 여기에
는 현재 작업 솔루션입니다? – robertjd
expandCustomData를 사용하지 않습니다 – Mike
해당 옵션을 추가 할 수 있습니까? 사후 등록 정보 핸들러 – robertjd