Skip to content

Commit

Permalink
fix password field confirmations
Browse files Browse the repository at this point in the history
  • Loading branch information
jaemk committed Mar 3, 2018
1 parent bd68771 commit 1d9d64a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
3 changes: 1 addition & 2 deletions web/src/components/Delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Delete extends Component {
}

delete() {
console.log(this.state);
let required = {};
if (this.state.key.length === 0) {
required.key = true;
Expand All @@ -60,7 +59,7 @@ class Delete extends Component {
responseStatus: resp.status,
});
}).catch(err => {
console.log(err);
console.error(err);
this.setState({responseStatus: err.response.status})
});
}
Expand Down
3 changes: 0 additions & 3 deletions web/src/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,17 @@ class NavBar extends Component {
}

mapUrlToNavKey(url) {
console.log('url:', url);
return URL_TO_INDEX[url];
}

handleSelect(eventKey) {
console.log('eventkey:', eventKey);
const url = INDEX_TO_URL[eventKey] || '/upload';
this.props.history.push(url);
}

render() {
const activeKey = this.mapUrlToNavKey(this.props.history.location.pathname);
const isDisabled = (eventKey) => activeKey === eventKey;
console.log('activekey:', activeKey);
return (
<div>
<Nav bsStyle="tabs" activeKey={activeKey} onSelect={this.handleSelect}>
Expand Down
7 changes: 4 additions & 3 deletions web/src/components/PasswordField.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PasswordField extends Component {
}

validate() {
const field1 = this.state.access;
const field1 = this.state.pass;
if (field1 && this.props.no_confirm) { return 'success'; }

const field2 = this.state.confirm;
Expand All @@ -39,8 +39,9 @@ class PasswordField extends Component {
this.props.update(val);
return
}
const updateVal = (val === otherVal)? val : '';
this.props.update(updateVal);
const valid = val === otherVal;
const updateVal = valid? val : '';
this.props.update(updateVal, valid);
}

return (
Expand Down
18 changes: 12 additions & 6 deletions web/src/components/Upload.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ class Upload extends Component {
super(props);
this.state = {
accessPass: '',
accessValid: false,
encryptPass: '',
encryptValid: false,
deletePass: '',
deletePassConfirm: '',
deleteValid: true,
downloadLimit: '',
lifespan: '',

Expand Down Expand Up @@ -50,12 +52,15 @@ class Upload extends Component {
if (!file) {
required.file = true;
}
if (this.state.accessPass.length === 0) {
if (this.state.accessPass.length === 0 || !this.state.accessValid) {
required.accessPass = true;
}
if (this.state.encryptPass.length === 0) {
if (this.state.encryptPass.length === 0 || !this.state.encryptValid) {
required.encryptPass = true;
}
if (!this.state.deleteValid) {
required.deletePass = true;
}

let errors = {};
const downloadLimit = (this.state.downloadLimit === '')? null : parseInt(this.state.downloadLimit, 10);
Expand Down Expand Up @@ -194,23 +199,24 @@ class Upload extends Component {
<PasswordField
title="Access"
disabled={disable}
update={(v) => this.setState({accessPass: v})}
update={(v, valid) => this.setState({accessPass: v, accessValid: valid})}
required={this.state.required.accessPass}
/>
<br/>

<PasswordField
title="Encrypt"
disabled={disable}
update={(v) => this.setState({encryptPass: v})}
update={(v, valid) => this.setState({encryptPass: v, encryptValid: valid})}
required={this.state.required.encryptPass}
/>
<br/>

<PasswordField
title="Delete"
disabled={disable}
update={(v) => this.setState({deletePass: v})}
update={(v, valid) => this.setState({deletePass: v, deleteValid: valid})}
required={this.state.required.deletePass}
/>
<br/>

Expand Down

0 comments on commit 1d9d64a

Please sign in to comment.