Skip to content

Latest commit

 

History

History
52 lines (35 loc) · 1.16 KB

README.md

File metadata and controls

52 lines (35 loc) · 1.16 KB

express-stormpath-enqueuer

npm version npm downloads

Ensures changes to user custom data don't overwrite unrelated data due to staleness.

Installation

$ npm install express-stormpath-enqueuer

Usage

Initialize

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);

Modify User Data

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);
});