couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowal...@apache.org
Subject [1/3] fauxton commit: updated refs/heads/master to 5de1fe6
Date Wed, 22 Jul 2015 12:17:07 GMT
Repository: couchdb-fauxton
Updated Branches:
  refs/heads/master c754c6cac -> 5de1fe668


Admin: Fix style issues

PR: #480
PR-URL: https://github.com/apache/couchdb-fauxton/pull/480
Reviewed-By: garren smith <garren.smith@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/commit/3896d202
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/tree/3896d202
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/diff/3896d202

Branch: refs/heads/master
Commit: 3896d202d368de90b2565cf16feb6fb3898a4376
Parents: 919a7f8
Author: Robert Kowalski <robertkowalski@apache.org>
Authored: Tue Jul 14 15:14:51 2015 +0200
Committer: Robert Kowalski <robertkowalski@apache.org>
Committed: Wed Jul 22 14:17:08 2015 +0200

----------------------------------------------------------------------
 app/addons/auth/resources.js | 43 +++++++++++++++++----------------------
 1 file changed, 19 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-fauxton/blob/3896d202/app/addons/auth/resources.js
----------------------------------------------------------------------
diff --git a/app/addons/auth/resources.js b/app/addons/auth/resources.js
index c3deed7..175a314 100644
--- a/app/addons/auth/resources.js
+++ b/app/addons/auth/resources.js
@@ -55,7 +55,6 @@ function (app, FauxtonAPI, CouchdbSession) {
 
       this.messages = _.extend({},  {
           missingCredentials: 'Username or password cannot be blank.',
-          passwordsNotMatch:  'Passwords do not match.',
           loggedIn: 'You have been logged in.',
           adminCreated: 'CouchDB admin created',
           changePassword: 'Your password has been updated.',
@@ -132,10 +131,9 @@ function (app, FauxtonAPI, CouchdbSession) {
     },
 
     createAdmin: function (username, password, login) {
-      var that = this,
-          error_promise =  this.validateUser(username, password, this.messages.missingCredentials);
+      var errorPromise = this.validateUser(username, password, this.messages.missingCredentials);
 
-      if (error_promise) { return error_promise; }
+      if (errorPromise) { return errorPromise; }
 
       var admin = new Admin({
         name: username,
@@ -144,19 +142,18 @@ function (app, FauxtonAPI, CouchdbSession) {
 
       return admin.save().then(function () {
         if (login) {
-          return that.login(username, password);
-        } else {
-          return that.fetchUser({forceFetch: true});
+          return this.login(username, password);
         }
-      });
+
+        return this.fetchUser({forceFetch: true});
+
+      }.bind(this));
     },
 
     login: function (username, password) {
-      var error_promise =  this.validateUser(username, password, this.messages.missingCredentials);
-
-      if (error_promise) { return error_promise; }
+      var errorPromise = this.validateUser(username, password, this.messages.missingCredentials);
 
-      var that = this;
+      if (errorPromise) { return errorPromise; }
 
       return $.ajax({
         cache: false,
@@ -165,8 +162,8 @@ function (app, FauxtonAPI, CouchdbSession) {
         dataType: "json",
         data: {name: username, password: password}
       }).then(function () {
-        return that.fetchUser({forceFetch: true});
-      });
+        return this.fetchUser({forceFetch: true});
+      }.bind(this));
     },
 
     logout: function () {
@@ -183,23 +180,21 @@ function (app, FauxtonAPI, CouchdbSession) {
       });
     },
 
-    changePassword: function (password, password_confirm) {
-      var error_promise =  this.validatePasswords(password, password_confirm, this.messages.passwordsNotMatch);
+    changePassword: function (password, confirmedPassword) {
+      var errorMessage = 'Passwords do not match.';
+      var errorPromise = this.validatePasswords(password, confirmedPassword, errorMessage);
 
-      if (error_promise) { return error_promise; }
-
-      var  that = this,
-           info = this.get('info'),
-           userCtx = this.get('userCtx');
+      if (errorPromise) { return errorPromise; }
 
+      var userName = this.get('userCtx').name;
       var admin = new Admin({
-        name: userCtx.name,
+        name: userName,
         value: password
       });
 
       return admin.save().then(function () {
-        return that.login(userCtx.name, password);
-      });
+        return this.login(userName, password);
+      }.bind(this));
     }
   });
 


Mime
View raw message