Github user garrensmith commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/669#discussion_r72035155
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -28,88 +28,135 @@ var errorHandler = function (xhr, type, msg) {
     };
     
     
    -export default {
    +function login (username, password, urlBack) {
    +  var promise = FauxtonAPI.session.login(username, password);
    +
    +  promise.then(function () {
    +    FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.loggedIn 
});
    +    if (urlBack) {
    +      return FauxtonAPI.navigate(urlBack);
    +    }
    +    FauxtonAPI.navigate('/');
    +  });
    +  promise.fail(errorHandler);
    +}
     
    -  login: function (username, password, urlBack) {
    -    var promise = FauxtonAPI.session.login(username, password);
    +function changePassword (password, passwordConfirm) {
    +  var nodes = nodesStore.getNodes();
    +  var promise = FauxtonAPI.session.changePassword(password, 
passwordConfirm, nodes[0].node);
     
    -    promise.then(function () {
    -      FauxtonAPI.addNotification({ msg: 
FauxtonAPI.session.messages.loggedIn });
    -      if (urlBack) {
    -        return FauxtonAPI.navigate(urlBack);
    -      }
    -      FauxtonAPI.navigate('/');
    -    });
    -    promise.fail(errorHandler);
    -  },
    +  promise.done(function () {
    +    FauxtonAPI.addNotification({ msg: 
FauxtonAPI.session.messages.changePassword });
    +    FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS 
});
    +  });
     
    -  changePassword: function (password, passwordConfirm) {
    -    var nodes = nodesStore.getNodes();
    -    var promise = FauxtonAPI.session.changePassword(password, 
passwordConfirm, nodes[0].node);
    +  promise.fail(errorHandler);
    +}
     
    -    promise.done(function () {
    -      FauxtonAPI.addNotification({ msg: 
FauxtonAPI.session.messages.changePassword });
    -      FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS 
});
    -    });
    +function updateChangePasswordField (value) {
    +  FauxtonAPI.dispatch({
    +    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +    value: value
    +  });
    +}
    +
    +function updateChangePasswordConfirmField (value) {
    +  FauxtonAPI.dispatch({
    +    type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +    value: value
    +  });
    +}
     
    -    promise.fail(errorHandler);
    -  },
    +function createAdmin (username, password, loginAfter) {
    +  var nodes = nodesStore.getNodes();
    +  var promise = FauxtonAPI.session.createAdmin(username, password, 
loginAfter, nodes[0].node);
     
    -  updateChangePasswordField: function (value) {
    -    FauxtonAPI.dispatch({
    -      type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    -      value: value
    -    });
    -  },
    +  promise.then(function () {
    +    FauxtonAPI.addNotification({ msg: 
FauxtonAPI.session.messages.adminCreated });
    +    if (loginAfter) {
    +      FauxtonAPI.navigate('/');
    +    } else {
    +      FauxtonAPI.dispatch({ type: 
ActionTypes.AUTH_CLEAR_CREATE_ADMIN_FIELDS });
    +    }
    +  });
     
    -  updateChangePasswordConfirmField: function (value) {
    +  promise.fail(function (xhr, type, msg) {
    --- End diff --
    
    Could you rather use the second function in the `then` promise to handle 
the fail case.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to