garrensmith commented on a change in pull request #923: Clean up Auth section
URL: https://github.com/apache/couchdb-fauxton/pull/923#discussion_r120007706
 
 

 ##########
 File path: app/addons/auth/components/changepasswordform.js
 ##########
 @@ -0,0 +1,97 @@
+// 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.
+
+import React from "react";
+import ReactDOM from "react-dom";
+import FauxtonAPI from '../../../core/api';
+import {
+  changePassword
+} from "./../actions";
+
+import {connect} from 'react-redux';
+
+export class ChangePasswordForm extends React.Component {
+
+  constructor(props) {
+    super(props);
+    this.state = {
+      password: '',
+      passwordConfirm: ''
+    };
+  }
+
+  onChangePassword(e) {
+    this.setState({password: e.target.value});
+  }
+
+  onChangePasswordConfirm(e) {
+    this.setState({passwordConfirm: e.target.value});
+  }
+
+  componentDidMount() {
+    ReactDOM.findDOMNode(this.refs.password).focus();
+  }
+
+  changePassword(e) {
+    e.preventDefault();
+    this.props.changePassword(this.props.username, this.state.password, 
this.state.passwordConfirm);
+  }
+
+  render() {
+    return (
+      <div className="faux__auth-page">
+        <h3>Change Password</h3>
+
+        <form id="change-password" onSubmit={this.changePassword.bind(this)}>
+          <p>
+            Enter your new password.
+          </p>
+
+          <input
+            id="password"
+            type="password"
+            ref="password"
+            name="password"
+            placeholder="Password"
+            size="24"
+            onChange={this.onChangePassword.bind(this)}
+            value={this.state.password}
+          />
+          <br />
+          <input
+            id="password-confirm"
+            type="password"
+            name="password_confirm"
+            placeholder="Verify Password"
+            size="24"
+            onChange={this.onChangePasswordConfirm.bind(this)}
+            value={this.state.passwordConfirm}
+          />
+
+          <br />
+          <p>
+            <button type="submit" className="btn btn-primary">Change</button>
+          </p>
+        </form>
+      </div>
+    );
+  }
+}
+
+export default connect(
 
 Review comment:
   I don't really follow what you mean here? Normally this component would be 
the container with more "dumb" components inside but because its a simple 
section I decided not to add any more components. In terms of using redux, I'm 
not using a store/reducer at all and rather keeping the state in the component. 
I gave this quite a bit of thought and couldn't find a good reason to use a 
reducer here since its just capturing some basic info. 
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to