Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

room-lock: adds ability to allow only digits for room locking

Дамян Минковd16e10baecec
diff --git a/config.js b/config.js
index 3589d3d23b..e7348a06e3 100644
--- a/config.js
+++ b/config.js
@@ -269,6 +269,10 @@ var config = {
// Enable lock room for all moderators, even when userRolesBasedOnToken is enabled and participants are guests.
// lockRoomGuestEnabled: false,
+ // When enabled the password used for locking a room is restricted to up to the number of digits specified
+ // roomPasswordNumberOfDigits: 10,
+ // default: roomPasswordNumberOfDigits: false,
+
// Message to show the users. Example: 'The service will be down for
// maintenance at 01:00 AM GMT,
// noticeMessage: '',
diff --git a/lang/main.json b/lang/main.json
index 767c9c4d1e..eec7a3c842 100644
--- a/lang/main.json
+++ b/lang/main.json
@@ -485,6 +485,7 @@
"newDeviceAction": "Use"
},
"passwordSetRemotely": "set by another member",
+ "passwordDigitsOnly": "Up to __number__ digits",
"poweredby": "powered by",
"presenceStatus": {
"busy": "Busy",
diff --git a/react/features/base/dialog/components/native/InputDialog.js b/react/features/base/dialog/components/native/InputDialog.js
index 63568569a5..c97dbd2bab 100644
--- a/react/features/base/dialog/components/native/InputDialog.js
+++ b/react/features/base/dialog/components/native/InputDialog.js
@@ -32,7 +32,12 @@ type Props = BaseProps & {
t: Function,
- textInputProps: ?Object
+ textInputProps: ?Object,
+
+ /**
+ * Validating of the input.
+ */
+ validateInput: ?Function
}
type State = {
@@ -118,6 +123,12 @@ class InputDialog extends BaseDialog<Props, State> {
* @returns {void}
*/
_onChangeText(fieldValue) {
+
+ if (this.props.validateInput
+ && !this.props.validateInput(fieldValue)) {
+ return;
+ }
+
this.setState({
fieldValue
});
diff --git a/react/features/invite/components/info-dialog/web/InfoDialog.js b/react/features/invite/components/info-dialog/web/InfoDialog.js
index a1b5c886f6..20c8fafd9d 100644
--- a/react/features/invite/components/info-dialog/web/InfoDialog.js
+++ b/react/features/invite/components/info-dialog/web/InfoDialog.js
@@ -40,6 +40,11 @@ type Props = {
*/
_conferenceName: string,
+ /**
+ * The number of digits to be used in the password.
+ */
+ _passwordNumberOfDigits: ?number,
+
/**
* The current url of the conference to be copied onto the clipboard.
*/
@@ -245,7 +250,8 @@ class InfoDialog extends Component<Props, State> {
editEnabled = { this.state.passwordEditEnabled }
locked = { this.props._locked }
onSubmit = { this._onPasswordSubmit }
- password = { this.props._password } />
+ password = { this.props._password }
+ passwordNumberOfDigits = { this.props._passwordNumberOfDigits } />
</div>
<div className = 'info-dialog-action-links'>
<div className = 'info-dialog-action-link'>
@@ -591,6 +597,7 @@ function _mapStateToProps(state) {
_canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
_conference: conference,
_conferenceName: room,
+ _passwordNumberOfDigits: state['features/base/config'].roomPasswordNumberOfDigits,
_inviteURL: getInviteURL(state),
_localParticipant: getLocalParticipant(state),
_locationURL: state['features/base/connection'].locationURL,
diff --git a/react/features/invite/components/info-dialog/web/PasswordForm.js b/react/features/invite/components/info-dialog/web/PasswordForm.js
index fa03d9ded7..394d163ff7 100644
--- a/react/features/invite/components/info-dialog/web/PasswordForm.js
+++ b/react/features/invite/components/info-dialog/web/PasswordForm.js
@@ -32,6 +32,11 @@ type Props = {
*/
password: string,
+ /**
+ * The number of digits to be used in the password.
+ */
+ passwordNumberOfDigits: boolean,
+
/**
* Invoked to obtain translated strings.
*/
@@ -117,6 +122,14 @@ class PasswordForm extends Component<Props, State> {
*/
_renderPasswordField() {
if (this.props.editEnabled) {
+ let digitPattern, placeHolderText;
+
+ if (this.props.passwordNumberOfDigits) {
+ placeHolderText = this.props.t('passwordDigitsOnly', {
+ number: this.props.passwordNumberOfDigits });
+ digitPattern = '\\d*';
+ }
+
return (
<form
className = 'info-password-form'
@@ -125,7 +138,10 @@ class PasswordForm extends Component<Props, State> {
<input
autoFocus = { true }
className = 'info-password-input'
+ maxLength = { this.props.passwordNumberOfDigits }
onChange = { this._onEnteredPasswordChange }
+ pattern = { digitPattern }
+ placeholder = { placeHolderText }
spellCheck = { 'false' }
type = 'text'
value = { this.state.enteredPassword } />
diff --git a/react/features/room-lock/actions.js b/react/features/room-lock/actions.js
index 4e29d304dc..83a0f6aecf 100644
--- a/react/features/room-lock/actions.js
+++ b/react/features/room-lock/actions.js
@@ -25,7 +25,11 @@ export function beginRoomLockRequest(conference: ?Object) {
conference = getState()['features/base/conference'].conference;
}
if (conference) {
- dispatch(openDialog(RoomLockPrompt, { conference }));
+ const passwordNumberOfDigits = getState()['features/base/config'].roomPasswordNumberOfDigits;
+
+ dispatch(openDialog(RoomLockPrompt, {
+ conference,
+ passwordNumberOfDigits }));
}
};
}
diff --git a/react/features/room-lock/components/RoomLockPrompt.native.js b/react/features/room-lock/components/RoomLockPrompt.native.js
index 503a4e5357..a369c68839 100644
--- a/react/features/room-lock/components/RoomLockPrompt.native.js
+++ b/react/features/room-lock/components/RoomLockPrompt.native.js
@@ -28,10 +28,15 @@ type Props = {
*/
conference: Object,
+ /**
+ * The number of digits to be used in the password.
+ */
+ passwordNumberOfDigits: ?number,
+
/**
* Redux store dispatch function.
*/
- dispatch: Dispatch<any>,
+ dispatch: Dispatch<any>
};
/**
@@ -51,6 +56,7 @@ class RoomLockPrompt extends Component<Props> {
// Bind event handlers so they are only bound once per instance.
this._onCancel = this._onCancel.bind(this);
this._onSubmit = this._onSubmit.bind(this);
+ this._validateInput = this._validateInput.bind(this);
}
/**
@@ -60,12 +66,23 @@ class RoomLockPrompt extends Component<Props> {
* @returns {ReactElement}
*/
render() {
+ let textInputProps = _TEXT_INPUT_PROPS;
+
+ if (this.props.passwordNumberOfDigits) {
+ textInputProps = {
+ ...textInputProps,
+ keyboardType: 'number-pad',
+ maxLength: this.props.passwordNumberOfDigits
+ };
+ }
+
return (
<InputDialog
contentKey = 'dialog.passwordLabel'
onCancel = { this._onCancel }
onSubmit = { this._onSubmit }
- textInputProps = { _TEXT_INPUT_PROPS } />
+ textInputProps = { textInputProps }
+ validateInput = { this._validateInput } />
);
}
@@ -100,6 +117,28 @@ class RoomLockPrompt extends Component<Props> {
return false; // Do not hide.
}
+
+ _validateInput: (string) => boolean;
+
+ /**
+ * Verifies input in case only digits are required.
+ *
+ * @param {string|undefined} value - The submitted value.
+ * @private
+ * @returns {boolean} False when the value is not valid and True otherwise.
+ */
+ _validateInput(value: string) {
+
+ // we want only digits, but both number-pad and numeric add ',' and '.' as symbols
+ if (this.props.passwordNumberOfDigits
+ && value.length > 0
+ && !/^\d+$/.test(value)) {
+
+ return false;
+ }
+
+ return true;
+ }
}
export default connect()(RoomLockPrompt);