couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From robertkowalski <...@git.apache.org>
Subject [GitHub] couchdb-fauxton pull request: Updating Auth module to use React
Date Tue, 21 Apr 2015 10:42:20 GMT
Github user robertkowalski commented on a diff in the pull request:

    https://github.com/apache/couchdb-fauxton/pull/390#discussion_r28766966
  
    --- Diff: app/addons/auth/actions.js ---
    @@ -0,0 +1,116 @@
    +// Licensed under the Apache License, Version 2.0 (the "License"); you may not
    +// use this file except in compliance with the License. You may obtain a copy of
    +// the License at
    +//
    +//   http://www.apache.org/licenses/LICENSE-2.0
    +//
    +// Unless required by applicable law or agreed to in writing, software
    +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    +// License for the specific language governing permissions and limitations under
    +// the License.
    +define([
    +  'api',
    +  'addons/auth/actiontypes'
    +],
    +function (FauxtonAPI, ActionTypes) {
    +
    +
    +  var errorHandler = function (xhr, type, msg) {
    +    msg = xhr;
    +    if (arguments.length === 3) {
    +      msg = xhr.responseJSON.reason;
    +    }
    +
    +    FauxtonAPI.addNotification({
    +      msg: msg,
    +      type: 'error'
    +    });
    +  };
    +
    +
    +  return {
    +
    +    login: function (username, password, session, urlBack) {
    +      var promise = 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);
    +    },
    +
    +    changePassword: function (password, passwordConfirm, session) {
    +      var promise = session.changePassword(password, passwordConfirm);
    +
    +      promise.done(function () {
    +        FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.changePassword
});
    +        FauxtonAPI.dispatch({ type: ActionTypes.AUTH_CLEAR_CHANGE_PWD_FIELDS });
    +      });
    +
    +      promise.fail(errorHandler);
    +    },
    +
    +    updateChangePasswordField: function (value) {
    +      FauxtonAPI.dispatch({
    +        type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_FIELD,
    +        value: value
    +      });
    +    },
    +
    +    updateChangePasswordConfirmField: function (value) {
    +      FauxtonAPI.dispatch({
    +        type: ActionTypes.AUTH_UPDATE_CHANGE_PWD_CONFIRM_FIELD,
    +        value: value
    +      });
    +    },
    +
    +    createAdmin: function (username, password, session, loginAfter) {
    +      var promise = session.createAdmin(username, password, loginAfter);
    +
    +      promise.then(function () {
    +        FauxtonAPI.addNotification({ msg: FauxtonAPI.session.messages.adminCreated });
    --- End diff --
    
    I noticed that `session` is injected and also used from our `FauxtonAPI`
    
    I was not aware that session is available on the `FauxtonAPI`-object - I think we can
just use `FauxtonAPI.session` everywhere? Are there reasons against using it?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message