Storage Example

Server

See the included example for a full template.

Client

In this example we change the destination of the user settings:

(function(_super) {
  function MyStorage() {
    _super(this, arguments);
  }

  MyStorage.prototype = Object.create(_super.prototype);
  MyStorage.constructor = _super;

  MyStorage.prototype.saveSettings = function(pool, storage, callback) {
    var username = OSjs.Core.getAuthenticator().getUser().username;

    someExternalApi.save(username, {
      settings: storage
    }).then(function(err) {
      callback(err);
    }).catch(function() {
      callback(null, true);
    });
  };
})(OSjs.Core.Storage);