From c871b3f9487b9bfeb3726d763a632a772b420a0a Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Sun, 11 Oct 2020 16:42:07 -0700 Subject: [PATCH] Fixed: Copying passwords Closes #4011 --- frontend/src/Components/Form/PasswordInput.js | 7 +++++++ frontend/src/Components/Form/TextInput.js | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/frontend/src/Components/Form/PasswordInput.js b/frontend/src/Components/Form/PasswordInput.js index adb1e7c5a..fef54fd5a 100644 --- a/frontend/src/Components/Form/PasswordInput.js +++ b/frontend/src/Components/Form/PasswordInput.js @@ -3,10 +3,17 @@ import React from 'react'; import TextInput from './TextInput'; import styles from './PasswordInput.css'; +// Prevent a user from copying (or cutting) the password from the input +function onCopy(e) { + e.preventDefault(); + e.nativeEvent.stopImmediatePropagation(); +} + function PasswordInput(props) { return ( ); } diff --git a/frontend/src/Components/Form/TextInput.js b/frontend/src/Components/Form/TextInput.js index cc0cbca02..4c71054d4 100644 --- a/frontend/src/Components/Form/TextInput.js +++ b/frontend/src/Components/Form/TextInput.js @@ -130,7 +130,8 @@ class TextInput extends Component { step, min, max, - onBlur + onBlur, + onCopy } = this.props; return ( @@ -155,6 +156,8 @@ class TextInput extends Component { onChange={this.onChange} onFocus={this.onFocus} onBlur={onBlur} + onCopy={onCopy} + onCut={onCopy} onKeyUp={this.onKeyUp} onMouseDown={this.onMouseDown} onMouseUp={this.onMouseUp} @@ -180,6 +183,7 @@ TextInput.propTypes = { onChange: PropTypes.func.isRequired, onFocus: PropTypes.func, onBlur: PropTypes.func, + onCopy: PropTypes.func, onSelectionChange: PropTypes.func };