Skip to content

Commit

Permalink
Fixed: Copying passwords
Browse files Browse the repository at this point in the history
(cherry picked from commit c871b3f9487b9bfeb3726d763a632a772b420a0a)
  • Loading branch information
markus101 authored and Qstick committed Oct 14, 2020
1 parent c00cbb8 commit e5e69be
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions frontend/src/Components/Form/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<TextInput
{...props}
onCopy={onCopy}
/>
);
}
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/Components/Form/TextInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ class TextInput extends Component {
step,
min,
max,
onBlur
onBlur,
onCopy
} = this.props;

return (
Expand All @@ -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}
Expand All @@ -180,6 +183,7 @@ TextInput.propTypes = {
onChange: PropTypes.func.isRequired,
onFocus: PropTypes.func,
onBlur: PropTypes.func,
onCopy: PropTypes.func,
onSelectionChange: PropTypes.func
};

Expand Down

0 comments on commit e5e69be

Please sign in to comment.