mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-12 13:24:52 +00:00
repair password-bug
This commit is contained in:
@@ -11,19 +11,29 @@ class WebdavPassword extends React.Component {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
isPasswordVisible: false,
|
isPasswordHidden: true,
|
||||||
password: webdavPasswd
|
password: webdavPasswd
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.passwordInput = React.createRef();
|
||||||
}
|
}
|
||||||
|
|
||||||
handleInputChange = (e) => {
|
handleInputChange = (e) => {
|
||||||
let passwd = e.target.value.trim();
|
let passwd = e.target.value.trim();
|
||||||
this.setState({password: passwd});
|
this.setState({password: passwd}, () => {
|
||||||
|
if (this.state.isPasswordHidden) {
|
||||||
|
this.passwordInput.type = 'password';
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
togglePasswordVisible = () => {
|
togglePasswordVisible = () => {
|
||||||
this.setState({
|
this.setState({isPasswordHidden: !this.state.isPasswordHidden}, () => {
|
||||||
isPasswordVisible: !this.state.isPasswordVisible
|
if (this.state.isPasswordHidden) {
|
||||||
|
this.passwordInput.type = 'password';
|
||||||
|
} else {
|
||||||
|
this.passwordInput.type = 'text';
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +45,9 @@ class WebdavPassword extends React.Component {
|
|||||||
}
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
password: randomPassword,
|
password: randomPassword,
|
||||||
isPasswordVisible: true
|
isPasswordHidden: false,
|
||||||
|
}, () => {
|
||||||
|
this.passwordInput.type = 'text';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,9 +74,7 @@ class WebdavPassword extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleDelete = () => {
|
handleDelete = () => {
|
||||||
this.setState({
|
this.setState({password: ''});
|
||||||
password: ''
|
|
||||||
});
|
|
||||||
this.updatePassword('');
|
this.updatePassword('');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,9 +85,9 @@ class WebdavPassword extends React.Component {
|
|||||||
<label>{gettext('Password')}</label>
|
<label>{gettext('Password')}</label>
|
||||||
<div className="row mb-2">
|
<div className="row mb-2">
|
||||||
<InputGroup className="col-sm-5">
|
<InputGroup className="col-sm-5">
|
||||||
<Input type={this.state.isPasswordVisible ? 'text' : 'password'} value={this.state.password} onChange={this.handleInputChange} />
|
<Input innerRef={input => {this.passwordInput = input}} value={this.state.password} onChange={this.handleInputChange} autoComplete="new-password"/>
|
||||||
<InputGroupAddon addonType="append">
|
<InputGroupAddon addonType="append">
|
||||||
<Button onClick={this.togglePasswordVisible}><i className={`fas ${this.state.isPasswordVisible ? 'fa-eye': 'fa-eye-slash'}`}></i></Button>
|
<Button onClick={this.togglePasswordVisible}><i className={`fas ${this.state.isPasswordHidden ? 'fa-eye': 'fa-eye-slash'}`}></i></Button>
|
||||||
<Button onClick={this.generatePassword}><i className="fas fa-magic"></i></Button>
|
<Button onClick={this.generatePassword}><i className="fas fa-magic"></i></Button>
|
||||||
</InputGroupAddon>
|
</InputGroupAddon>
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
|
Reference in New Issue
Block a user