Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B0967104FE for ; Sun, 16 Mar 2014 16:58:29 +0000 (UTC) Received: (qmail 42863 invoked by uid 500); 16 Mar 2014 16:58:05 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 42013 invoked by uid 500); 16 Mar 2014 16:57:45 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 41771 invoked by uid 99); 16 Mar 2014 16:57:41 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 16 Mar 2014 16:57:41 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 568DE946D02; Sun, 16 Mar 2014 16:57:41 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dch@apache.org To: commits@couchdb.apache.org Date: Sun, 16 Mar 2014 16:57:45 -0000 Message-Id: <75d33215a0cb4524bf6073d5d9638ad7@git.apache.org> In-Reply-To: <726e9b3d119545c0a1689da2a1e0bd96@git.apache.org> References: <726e9b3d119545c0a1689da2a1e0bd96@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [05/29] couchdb commit: updated refs/heads/2041-update-ibrowse to b63f393 Fauxton: dry up promise error callbacks Fauxton: Fix error if anon. user tries to create Admins Fixes #COUCHDB-2170 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b63ff1b5 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b63ff1b5 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b63ff1b5 Branch: refs/heads/2041-update-ibrowse Commit: b63ff1b50b7bde0c8f1f95988d076dda63f41fed Parents: fb4e845 Author: Robert Kowalski Authored: Thu Mar 6 11:37:17 2014 -0500 Committer: suelockwood Committed: Thu Mar 6 11:40:30 2014 -0500 ---------------------------------------------------------------------- src/fauxton/app/addons/auth/resources.js | 44 +++++++++------------------ 1 file changed, 15 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/b63ff1b5/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 2e359c9..71744e3 100644 --- a/src/fauxton/app/addons/auth/resources.js +++ b/src/fauxton/app/addons/auth/resources.js @@ -20,6 +20,18 @@ function (app, FauxtonAPI, CouchdbSession) { var Auth = new FauxtonAPI.addon(); + var promiseErrorHandler = function (xhr, type, msg) { + msg = xhr; + if (arguments.length === 3) { + msg = xhr.responseJSON.reason; + } + + FauxtonAPI.addNotification({ + msg: msg, + type: 'error' + }); + }; + var Admin = Backbone.Model.extend({ url: function () { @@ -58,7 +70,6 @@ function (app, FauxtonAPI, CouchdbSession) { this.messages = _.extend({}, { missingCredentials: 'Username or password cannot be blank.', passwordsNotMatch: 'Passwords do not match.', - incorrectCredentials: 'Incorrect username or password.', loggedIn: 'You have been logged in.', adminCreated: 'CouchDB admin created', changePassword: 'Your password has been updated.' @@ -234,12 +245,7 @@ function (app, FauxtonAPI, CouchdbSession) { } }); - promise.fail(function (rsp) { - FauxtonAPI.addNotification({ - msg: 'Could not create admin. Reason' + rsp + '.', - type: 'error' - }); - }); + promise.fail(promiseErrorHandler); } }); @@ -264,18 +270,7 @@ function (app, FauxtonAPI, CouchdbSession) { FauxtonAPI.navigate('/'); }); - promise.fail(function (xhr, type, msg) { - if (arguments.length === 3) { - msg = FauxtonAPI.session.messages.incorrectCredentials; - } else { - msg = xhr; - } - - FauxtonAPI.addNotification({ - msg: msg, - type: 'error' - }); - }); + promise.fail(promiseErrorHandler); } }); @@ -302,16 +297,7 @@ function (app, FauxtonAPI, CouchdbSession) { that.$('#password-confirm').val(''); }); - promise.fail(function (xhr, error, msg) { - if (arguments.length < 3) { - msg = xhr; - } - - FauxtonAPI.addNotification({ - msg: xhr, - type: 'error' - }); - }); + promise.fail(promiseErrorHandler); } });