0

I'm having a bit of trouble figuring out how to use Waterlock. I'm working with Sails.js and Angularjs, and I'm not sure how to update user attributes on a Waterlock authenticated user in a Sails controller. Should I not write my own controller for this? Is there a standard way to update a user through an API call in Sails or Waterlock?

1 Answers1

0

I found the solution in case anyone else is stuck here. You can access the authenticated user's data in req.session.user, and you will update the user through the Waterline ORM.

Here's some sample code:

module.exports = require('waterlock').actions.user({
  updateCurrentUser: function(req, res) {
    User.update(req.session.user.id, req.body)
      .exec(function(err, changes) {
        return res.json(changes);
      });
  }
});