remove reliance on config module for auth module
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/08644bf2 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/08644bf2 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/08644bf2 Branch: refs/heads/route-events Commit: 08644bf2d5d8cdb3064498dd59a3c33aaa951eca Parents: 1f52687 Author: Garren Smith <[email protected]> Authored: Thu May 9 09:58:08 2013 +0200 Committer: Garren Smith <[email protected]> Committed: Thu May 9 09:58:08 2013 +0200 ---------------------------------------------------------------------- src/fauxton/app/addons/auth/resources.js | 39 ++++++++++++++++++++---- src/fauxton/app/modules/fauxton/base.js | 1 + 2 files changed, 33 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/08644bf2/src/fauxton/app/addons/auth/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/auth/resources.js b/src/fauxton/app/addons/auth/resources.js index 5b61d50..64dd254 100644 --- a/src/fauxton/app/addons/auth/resources.js +++ b/src/fauxton/app/addons/auth/resources.js @@ -12,11 +12,38 @@ define([ "app", - "api", - "addons/config/resources" + "api" ], -function (app, FauxtonAPI, Config) { +function (app, FauxtonAPI) { + + var Admin = Backbone.Model.extend({ + + url: function () { + return app.host + '/_config/admins/' + this.get("name"); + }, + + isNew: function () { return false; }, + + sync: function (method, model, options) { + + var params = { + url: model.url(), + contentType: 'application/json', + dataType: 'json', + data: JSON.stringify(model.get('value')) + }; + + if (method === 'delete') { + params.type = 'DELETE'; + } else { + params.type = 'PUT'; + } + + return $.ajax(params); + } + }); + var Auth = new FauxtonAPI.addon(); Auth.Session = Backbone.Model.extend({ @@ -78,8 +105,7 @@ function (app, FauxtonAPI, Config) { if (error_promise) { return error_promise; } - var admin = new Config.OptionModel({ - section: "admins", + var admin = new Admin({ name: username, value: password }); @@ -133,8 +159,7 @@ function (app, FauxtonAPI, Config) { info = this.get('info'), userCtx = this.get('userCtx'); - var admin = new Config.OptionModel({ - section: "admins", + var admin = new Admin({ name: userCtx.name, value: password }); http://git-wip-us.apache.org/repos/asf/couchdb/blob/08644bf2/src/fauxton/app/modules/fauxton/base.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/modules/fauxton/base.js b/src/fauxton/app/modules/fauxton/base.js index 91ea581..fbdb402 100644 --- a/src/fauxton/app/modules/fauxton/base.js +++ b/src/fauxton/app/modules/fauxton/base.js @@ -72,6 +72,7 @@ function(app, Backbone) { _.each(this.navLinks, function (link) { if (!link.view) { return; } + //TODO check if establish is a function var establish = link.establish || []; $.when.apply(null, establish).done( function () { self.insertView('#nav-links', link.view).render();
