forked from p15670423/monkey
UI: Add hide/show component for credentials
This commit is contained in:
parent
dd390ff41d
commit
9a0837656b
|
@ -48,7 +48,9 @@ BASIC = {
|
||||||
"title": "Exploit password list",
|
"title": "Exploit password list",
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"uniqueItems": True,
|
"uniqueItems": True,
|
||||||
"items": {"type": "string"},
|
"items": {
|
||||||
|
"type": "string",
|
||||||
|
},
|
||||||
"default": [
|
"default": [
|
||||||
"root",
|
"root",
|
||||||
"123456",
|
"123456",
|
||||||
|
|
|
@ -3,6 +3,7 @@ import PbaInput from './PbaInput';
|
||||||
import {API_PBA_LINUX, API_PBA_WINDOWS} from '../pages/ConfigurePage';
|
import {API_PBA_LINUX, API_PBA_WINDOWS} from '../pages/ConfigurePage';
|
||||||
import InfoBox from './InfoBox';
|
import InfoBox from './InfoBox';
|
||||||
import TextBox from './TextBox';
|
import TextBox from './TextBox';
|
||||||
|
import HideInput from '../ui-components/HideInput';
|
||||||
|
|
||||||
export default function UiSchema(props) {
|
export default function UiSchema(props) {
|
||||||
const UiSchema = {
|
const UiSchema = {
|
||||||
|
@ -13,6 +14,13 @@ export default function UiSchema(props) {
|
||||||
classNames: 'config-template-no-header',
|
classNames: 'config-template-no-header',
|
||||||
'ui:widget': AdvancedMultiSelect
|
'ui:widget': AdvancedMultiSelect
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
credentials : {
|
||||||
|
exploit_password_list: {
|
||||||
|
items: {
|
||||||
|
'ui:widget': HideInput
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
basic_network: {
|
basic_network: {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
import React from 'react';
|
||||||
|
import {InputGroup, FormControl} from 'react-bootstrap';
|
||||||
|
import '../../styles/components/HideInput.scss'
|
||||||
|
|
||||||
|
class HideInput extends React.PureComponent {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
hidden: false
|
||||||
|
};
|
||||||
|
this.toggleShow = this.toggleShow.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleShow() {
|
||||||
|
this.setState({hidden: ! this.state.hidden});
|
||||||
|
}
|
||||||
|
|
||||||
|
onChange(e) {
|
||||||
|
var value = e.target.value;
|
||||||
|
return this.props.onChange(value === '' ? this.props.options.emptyValue : value);
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<InputGroup className='mb-3'>
|
||||||
|
<FormControl
|
||||||
|
value={this.props.value || ''}
|
||||||
|
type={this.state.hidden ? 'text' : 'password'}
|
||||||
|
onChange={(event) => this.onChange(event)}
|
||||||
|
/>
|
||||||
|
<InputGroup.Append>
|
||||||
|
<InputGroup.Text>
|
||||||
|
<i onClick={this.toggleShow} className={this.state.hidden ? 'fas fa-eye-slash' : 'fas fa-eye'}></i>
|
||||||
|
</InputGroup.Text>
|
||||||
|
</InputGroup.Append>
|
||||||
|
</InputGroup>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HideInput;
|
|
@ -0,0 +1,3 @@
|
||||||
|
.eye-button{
|
||||||
|
padding: 5px !important;
|
||||||
|
}
|
Loading…
Reference in New Issue