diff --git a/react/features/security/components/security-dialog/web/PasswordForm.js b/react/features/security/components/security-dialog/web/PasswordForm.js index 475461679..c9577ac66 100644 --- a/react/features/security/components/security-dialog/web/PasswordForm.js +++ b/react/features/security/components/security-dialog/web/PasswordForm.js @@ -85,9 +85,7 @@ class PasswordForm extends Component { super(props); // Bind event handlers so they are only bound once per instance. - this._onEnteredPasswordChange - = this._onEnteredPasswordChange.bind(this); - this._onPasswordSubmit = this._onPasswordSubmit.bind(this); + this._onEnteredPasswordChange = this._onEnteredPasswordChange.bind(this); this._onKeyPress = this._onKeyPress.bind(this); } @@ -122,31 +120,28 @@ class PasswordForm extends Component { */ _renderPasswordField() { if (this.props.editEnabled) { - let digitPattern, placeHolderText; + let placeHolderText; if (this.props.passwordNumberOfDigits) { placeHolderText = this.props.t('passwordDigitsOnly', { number: this.props.passwordNumberOfDigits }); - digitPattern = '\\d*'; } return ( -
+
- +
); } else if (this.props.locked === LOCKED_LOCALLY) { return ( @@ -182,23 +177,6 @@ class PasswordForm extends Component { this.setState({ enteredPassword: event.target.value }); } - _onPasswordSubmit: (Object) => void; - - /** - * Invokes the passed in onSubmit callback to notify the parent that a - * password submission has been attempted. - * - * @param {Object} event - DOM Event for form submission. - * @private - * @returns {void} - */ - _onPasswordSubmit(event) { - event.preventDefault(); - event.stopPropagation(); - - this.props.onSubmit(this.state.enteredPassword); - } - _onKeyPress: (Object) => void; /** @@ -211,7 +189,10 @@ class PasswordForm extends Component { */ _onKeyPress(event) { if (event.key === 'Enter') { + event.preventDefault(); event.stopPropagation(); + + this.props.onSubmit(this.state.enteredPassword); } } } diff --git a/react/features/security/components/security-dialog/web/PasswordSection.js b/react/features/security/components/security-dialog/web/PasswordSection.js index ac64f8859..56d1add1c 100644 --- a/react/features/security/components/security-dialog/web/PasswordSection.js +++ b/react/features/security/components/security-dialog/web/PasswordSection.js @@ -10,6 +10,7 @@ import { NOTIFY_CLICK_MODE } from '../../../../toolbox/constants'; import PasswordForm from './PasswordForm'; +const DIGITS_ONLY = /^\d+$/; const KEY = 'add-passcode'; type Props = { @@ -97,6 +98,10 @@ function PasswordSection({ * @returns {void} */ function onPasswordSubmit(enteredPassword) { + if (enteredPassword && passwordNumberOfDigits && !DIGITS_ONLY.test(enteredPassword)) { + // Don't set the password. + return; + } setPassword(conference, conference.lock, enteredPassword); } @@ -142,7 +147,7 @@ function PasswordSection({ */ function onPasswordSave() { if (formRef.current) { - const { value } = formRef.current.querySelector('form > input'); + const { value } = formRef.current.querySelector('div > input'); if (value) { onPasswordSubmit(value);