Stormpath のドキュメント には、PostRegistrationHandler でのユーザー属性の変更については何も記載されていません。これを行う必要があります。
ユーザーを作成した後、ランダムな文字列をプロパティとして指定したいと考えています。このランダムな文字列は、別の Mongo データベースのキーになります。私の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 は異なる必要があります。ユーザーを保存するにはどうすればよいですか?