Fix inability to authenticate against a server protected with HTTP Basic Auth

Remove use of refs for login dialog username and password, shift values into instance properties instead (#966)
This commit is contained in:
MikeNicholls
2019-05-12 08:02:14 +12:00
committed by William Gathoye
parent d662b5c863
commit 9aca5c6651

View File

@@ -9,17 +9,23 @@ export default class LoginModal extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.handleSubmit = this.handleSubmit.bind(this); this.handleSubmit = this.handleSubmit.bind(this);
this.usernameRef = React.createRef(); this.username = '';
this.passwordRef = React.createRef(); this.password = '';
} }
handleSubmit(event) { handleSubmit(event) {
event.preventDefault(); event.preventDefault();
const usernameNode = this.usernameRef.current; this.props.onLogin(this.props.request, this.username, this.password);
const passwordNode = this.passwordRef.current; this.username = '';
this.props.onLogin(this.props.request, usernameNode.value, passwordNode.value); this.password = '';
usernameNode.value = ''; }
passwordNode.value = '';
setUsername = (e) => {
this.username = e.target.value;
}
setPassword = (e) => {
this.password = e.target.value;
} }
render() { render() {
@@ -54,7 +60,7 @@ export default class LoginModal extends React.Component {
<FormControl <FormControl
type='text' type='text'
placeholder='User Name' placeholder='User Name'
ref={this.usernameRef} onChange={this.setUsername}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
}} }}
@@ -70,7 +76,7 @@ export default class LoginModal extends React.Component {
<FormControl <FormControl
type='password' type='password'
placeholder='Password' placeholder='Password'
ref={this.passwordRef} onChange={this.setPassword}
onClick={(e) => { onClick={(e) => {
e.stopPropagation(); e.stopPropagation();
}} }}