Ensures changes to user custom data don't overwrite unrelated data due to staleness.
$ npm install express-stormpath-enqueuer
var express = require('express');
var stormpath = require('express-stormpath');
var stormpathEnqueuer = require('express-stormpath-enqueuer');
var app = express();
app.use(stormpath.init(app, {...}));
stormpathEnqueuer.init(app);
app.use(stormpath.loginRequired);
app.use(stormpathEnqueuer.populate);
app.get('/', function(req, res, next) {
var callbacks = {
modify: function(customData) {
customData.myProperty = 'something useful';
},
onComplete: function(err, customData) {
console.log('DONE');
next();
}
}
req.stormpathEnqueuer.modifyCustomData(req.user.href, callbacks);
});