Skip to content
This repository has been archived by the owner on Mar 24, 2023. It is now read-only.

mask default password value #1101

Merged
merged 2 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@replicatedhq/ship-init",
"version": "1.6.15",
"version": "1.6.16",
"description": "Shared component that contains the Ship Init app",
"author": "Replicated, Inc.",
"license": "Apache-2.0",
Expand Down
11 changes: 10 additions & 1 deletion web/init/src/components/config_render/ConfigInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,21 @@ export default class ConfigInput extends React.Component {
this.setState({ inputVal: this.props.value });
}
}

maskValue = value => {
if (!value) {
return "";
}
return value.replace(/./g, '•');
}

// p1-2019-06-27
// Fields that are required sometimes don't have a title associated with them.
// Use title -OR- required prop to render <ConfigItemTitle> to make sure error
// elements are rendered.
render() {
var hidden = this.props.hidden || this.props.when === "false";
var placeholder = this.props.inputType === "password" ? this.maskValue(this.props.default) : this.props.default;

return (
<div className={`field field-type-text ${hidden ? "hidden" : "u-marginTop--15"}`}>
Expand All @@ -54,7 +63,7 @@ export default class ConfigInput extends React.Component {
ref={this.inputRef}
type={this.props.inputType}
{...this.props.props}
placeholder={this.props.default}
placeholder={placeholder}
value={this.state.inputVal}
readOnly={this.props.readonly}
disabled={this.props.readonly}
Expand Down