浏览代码

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

j8
Дамян Минков 6 年前
父节点
当前提交
d16e10baec

+ 4
- 0
config.js 查看文件

@@ -269,6 +269,10 @@ var config = {
269 269
     // Enable lock room for all moderators, even when userRolesBasedOnToken is enabled and participants are guests.
270 270
     // lockRoomGuestEnabled: false,
271 271
 
272
+    // When enabled the password used for locking a room is restricted to up to the number of digits specified
273
+    // roomPasswordNumberOfDigits: 10,
274
+    // default: roomPasswordNumberOfDigits: false,
275
+
272 276
     // Message to show the users. Example: 'The service will be down for
273 277
     // maintenance at 01:00 AM GMT,
274 278
     // noticeMessage: '',

+ 1
- 0
lang/main.json 查看文件

@@ -485,6 +485,7 @@
485 485
         "newDeviceAction": "Use"
486 486
     },
487 487
     "passwordSetRemotely": "set by another member",
488
+    "passwordDigitsOnly": "Up to __number__ digits",
488 489
     "poweredby": "powered by",
489 490
     "presenceStatus": {
490 491
         "busy": "Busy",

+ 12
- 1
react/features/base/dialog/components/native/InputDialog.js 查看文件

@@ -32,7 +32,12 @@ type Props = BaseProps & {
32 32
 
33 33
     t: Function,
34 34
 
35
-    textInputProps: ?Object
35
+    textInputProps: ?Object,
36
+
37
+    /**
38
+     * Validating of the input.
39
+     */
40
+    validateInput: ?Function
36 41
 }
37 42
 
38 43
 type State = {
@@ -118,6 +123,12 @@ class InputDialog extends BaseDialog<Props, State> {
118 123
      * @returns {void}
119 124
      */
120 125
     _onChangeText(fieldValue) {
126
+
127
+        if (this.props.validateInput
128
+                && !this.props.validateInput(fieldValue)) {
129
+            return;
130
+        }
131
+
121 132
         this.setState({
122 133
             fieldValue
123 134
         });

+ 8
- 1
react/features/invite/components/info-dialog/web/InfoDialog.js 查看文件

@@ -40,6 +40,11 @@ type Props = {
40 40
      */
41 41
     _conferenceName: string,
42 42
 
43
+    /**
44
+     * The number of digits to be used in the password.
45
+     */
46
+    _passwordNumberOfDigits: ?number,
47
+
43 48
     /**
44 49
      * The current url of the conference to be copied onto the clipboard.
45 50
      */
@@ -245,7 +250,8 @@ class InfoDialog extends Component<Props, State> {
245 250
                             editEnabled = { this.state.passwordEditEnabled }
246 251
                             locked = { this.props._locked }
247 252
                             onSubmit = { this._onPasswordSubmit }
248
-                            password = { this.props._password } />
253
+                            password = { this.props._password }
254
+                            passwordNumberOfDigits = { this.props._passwordNumberOfDigits } />
249 255
                     </div>
250 256
                     <div className = 'info-dialog-action-links'>
251 257
                         <div className = 'info-dialog-action-link'>
@@ -591,6 +597,7 @@ function _mapStateToProps(state) {
591 597
         _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
592 598
         _conference: conference,
593 599
         _conferenceName: room,
600
+        _passwordNumberOfDigits: state['features/base/config'].roomPasswordNumberOfDigits,
594 601
         _inviteURL: getInviteURL(state),
595 602
         _localParticipant: getLocalParticipant(state),
596 603
         _locationURL: state['features/base/connection'].locationURL,

+ 16
- 0
react/features/invite/components/info-dialog/web/PasswordForm.js 查看文件

@@ -32,6 +32,11 @@ type Props = {
32 32
      */
33 33
     password: string,
34 34
 
35
+    /**
36
+     * The number of digits to be used in the password.
37
+     */
38
+    passwordNumberOfDigits: boolean,
39
+
35 40
     /**
36 41
      * Invoked to obtain translated strings.
37 42
      */
@@ -117,6 +122,14 @@ class PasswordForm extends Component<Props, State> {
117 122
      */
118 123
     _renderPasswordField() {
119 124
         if (this.props.editEnabled) {
125
+            let digitPattern, placeHolderText;
126
+
127
+            if (this.props.passwordNumberOfDigits) {
128
+                placeHolderText = this.props.t('passwordDigitsOnly', {
129
+                    number: this.props.passwordNumberOfDigits });
130
+                digitPattern = '\\d*';
131
+            }
132
+
120 133
             return (
121 134
                 <form
122 135
                     className = 'info-password-form'
@@ -125,7 +138,10 @@ class PasswordForm extends Component<Props, State> {
125 138
                     <input
126 139
                         autoFocus = { true }
127 140
                         className = 'info-password-input'
141
+                        maxLength = { this.props.passwordNumberOfDigits }
128 142
                         onChange = { this._onEnteredPasswordChange }
143
+                        pattern = { digitPattern }
144
+                        placeholder = { placeHolderText }
129 145
                         spellCheck = { 'false' }
130 146
                         type = 'text'
131 147
                         value = { this.state.enteredPassword } />

+ 5
- 1
react/features/room-lock/actions.js 查看文件

@@ -25,7 +25,11 @@ export function beginRoomLockRequest(conference: ?Object) {
25 25
             conference = getState()['features/base/conference'].conference;
26 26
         }
27 27
         if (conference) {
28
-            dispatch(openDialog(RoomLockPrompt, { conference }));
28
+            const passwordNumberOfDigits = getState()['features/base/config'].roomPasswordNumberOfDigits;
29
+
30
+            dispatch(openDialog(RoomLockPrompt, {
31
+                conference,
32
+                passwordNumberOfDigits }));
29 33
         }
30 34
     };
31 35
 }

+ 41
- 2
react/features/room-lock/components/RoomLockPrompt.native.js 查看文件

@@ -28,10 +28,15 @@ type Props = {
28 28
      */
29 29
     conference: Object,
30 30
 
31
+    /**
32
+     * The number of digits to be used in the password.
33
+     */
34
+    passwordNumberOfDigits: ?number,
35
+
31 36
     /**
32 37
      * Redux store dispatch function.
33 38
      */
34
-    dispatch: Dispatch<any>,
39
+    dispatch: Dispatch<any>
35 40
 };
36 41
 
37 42
 /**
@@ -51,6 +56,7 @@ class RoomLockPrompt extends Component<Props> {
51 56
         // Bind event handlers so they are only bound once per instance.
52 57
         this._onCancel = this._onCancel.bind(this);
53 58
         this._onSubmit = this._onSubmit.bind(this);
59
+        this._validateInput = this._validateInput.bind(this);
54 60
     }
55 61
 
56 62
     /**
@@ -60,12 +66,23 @@ class RoomLockPrompt extends Component<Props> {
60 66
      * @returns {ReactElement}
61 67
      */
62 68
     render() {
69
+        let textInputProps = _TEXT_INPUT_PROPS;
70
+
71
+        if (this.props.passwordNumberOfDigits) {
72
+            textInputProps = {
73
+                ...textInputProps,
74
+                keyboardType: 'number-pad',
75
+                maxLength: this.props.passwordNumberOfDigits
76
+            };
77
+        }
78
+
63 79
         return (
64 80
             <InputDialog
65 81
                 contentKey = 'dialog.passwordLabel'
66 82
                 onCancel = { this._onCancel }
67 83
                 onSubmit = { this._onSubmit }
68
-                textInputProps = { _TEXT_INPUT_PROPS } />
84
+                textInputProps = { textInputProps }
85
+                validateInput = { this._validateInput } />
69 86
         );
70 87
     }
71 88
 
@@ -100,6 +117,28 @@ class RoomLockPrompt extends Component<Props> {
100 117
 
101 118
         return false; // Do not hide.
102 119
     }
120
+
121
+    _validateInput: (string) => boolean;
122
+
123
+    /**
124
+     * Verifies input in case only digits are required.
125
+     *
126
+     * @param {string|undefined} value - The submitted value.
127
+     * @private
128
+     * @returns {boolean} False when the value is not valid and True otherwise.
129
+     */
130
+    _validateInput(value: string) {
131
+
132
+        // we want only digits, but both number-pad and numeric add ',' and '.' as symbols
133
+        if (this.props.passwordNumberOfDigits
134
+            && value.length > 0
135
+            && !/^\d+$/.test(value)) {
136
+
137
+            return false;
138
+        }
139
+
140
+        return true;
141
+    }
103 142
 }
104 143
 
105 144
 export default connect()(RoomLockPrompt);

正在加载...
取消
保存