ソースを参照

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

j8
Дамян Минков 6年前
コミット
d16e10baec

+ 4
- 0
config.js ファイルの表示

269
     // Enable lock room for all moderators, even when userRolesBasedOnToken is enabled and participants are guests.
269
     // Enable lock room for all moderators, even when userRolesBasedOnToken is enabled and participants are guests.
270
     // lockRoomGuestEnabled: false,
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
     // Message to show the users. Example: 'The service will be down for
276
     // Message to show the users. Example: 'The service will be down for
273
     // maintenance at 01:00 AM GMT,
277
     // maintenance at 01:00 AM GMT,
274
     // noticeMessage: '',
278
     // noticeMessage: '',

+ 1
- 0
lang/main.json ファイルの表示

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

+ 12
- 1
react/features/base/dialog/components/native/InputDialog.js ファイルの表示

32
 
32
 
33
     t: Function,
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
 type State = {
43
 type State = {
118
      * @returns {void}
123
      * @returns {void}
119
      */
124
      */
120
     _onChangeText(fieldValue) {
125
     _onChangeText(fieldValue) {
126
+
127
+        if (this.props.validateInput
128
+                && !this.props.validateInput(fieldValue)) {
129
+            return;
130
+        }
131
+
121
         this.setState({
132
         this.setState({
122
             fieldValue
133
             fieldValue
123
         });
134
         });

+ 8
- 1
react/features/invite/components/info-dialog/web/InfoDialog.js ファイルの表示

40
      */
40
      */
41
     _conferenceName: string,
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
      * The current url of the conference to be copied onto the clipboard.
49
      * The current url of the conference to be copied onto the clipboard.
45
      */
50
      */
245
                             editEnabled = { this.state.passwordEditEnabled }
250
                             editEnabled = { this.state.passwordEditEnabled }
246
                             locked = { this.props._locked }
251
                             locked = { this.props._locked }
247
                             onSubmit = { this._onPasswordSubmit }
252
                             onSubmit = { this._onPasswordSubmit }
248
-                            password = { this.props._password } />
253
+                            password = { this.props._password }
254
+                            passwordNumberOfDigits = { this.props._passwordNumberOfDigits } />
249
                     </div>
255
                     </div>
250
                     <div className = 'info-dialog-action-links'>
256
                     <div className = 'info-dialog-action-links'>
251
                         <div className = 'info-dialog-action-link'>
257
                         <div className = 'info-dialog-action-link'>
591
         _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
597
         _canEditPassword: isLocalParticipantModerator(state, state['features/base/config'].lockRoomGuestEnabled),
592
         _conference: conference,
598
         _conference: conference,
593
         _conferenceName: room,
599
         _conferenceName: room,
600
+        _passwordNumberOfDigits: state['features/base/config'].roomPasswordNumberOfDigits,
594
         _inviteURL: getInviteURL(state),
601
         _inviteURL: getInviteURL(state),
595
         _localParticipant: getLocalParticipant(state),
602
         _localParticipant: getLocalParticipant(state),
596
         _locationURL: state['features/base/connection'].locationURL,
603
         _locationURL: state['features/base/connection'].locationURL,

+ 16
- 0
react/features/invite/components/info-dialog/web/PasswordForm.js ファイルの表示

32
      */
32
      */
33
     password: string,
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
      * Invoked to obtain translated strings.
41
      * Invoked to obtain translated strings.
37
      */
42
      */
117
      */
122
      */
118
     _renderPasswordField() {
123
     _renderPasswordField() {
119
         if (this.props.editEnabled) {
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
             return (
133
             return (
121
                 <form
134
                 <form
122
                     className = 'info-password-form'
135
                     className = 'info-password-form'
125
                     <input
138
                     <input
126
                         autoFocus = { true }
139
                         autoFocus = { true }
127
                         className = 'info-password-input'
140
                         className = 'info-password-input'
141
+                        maxLength = { this.props.passwordNumberOfDigits }
128
                         onChange = { this._onEnteredPasswordChange }
142
                         onChange = { this._onEnteredPasswordChange }
143
+                        pattern = { digitPattern }
144
+                        placeholder = { placeHolderText }
129
                         spellCheck = { 'false' }
145
                         spellCheck = { 'false' }
130
                         type = 'text'
146
                         type = 'text'
131
                         value = { this.state.enteredPassword } />
147
                         value = { this.state.enteredPassword } />

+ 5
- 1
react/features/room-lock/actions.js ファイルの表示

25
             conference = getState()['features/base/conference'].conference;
25
             conference = getState()['features/base/conference'].conference;
26
         }
26
         }
27
         if (conference) {
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
      */
28
      */
29
     conference: Object,
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
      * Redux store dispatch function.
37
      * Redux store dispatch function.
33
      */
38
      */
34
-    dispatch: Dispatch<any>,
39
+    dispatch: Dispatch<any>
35
 };
40
 };
36
 
41
 
37
 /**
42
 /**
51
         // Bind event handlers so they are only bound once per instance.
56
         // Bind event handlers so they are only bound once per instance.
52
         this._onCancel = this._onCancel.bind(this);
57
         this._onCancel = this._onCancel.bind(this);
53
         this._onSubmit = this._onSubmit.bind(this);
58
         this._onSubmit = this._onSubmit.bind(this);
59
+        this._validateInput = this._validateInput.bind(this);
54
     }
60
     }
55
 
61
 
56
     /**
62
     /**
60
      * @returns {ReactElement}
66
      * @returns {ReactElement}
61
      */
67
      */
62
     render() {
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
         return (
79
         return (
64
             <InputDialog
80
             <InputDialog
65
                 contentKey = 'dialog.passwordLabel'
81
                 contentKey = 'dialog.passwordLabel'
66
                 onCancel = { this._onCancel }
82
                 onCancel = { this._onCancel }
67
                 onSubmit = { this._onSubmit }
83
                 onSubmit = { this._onSubmit }
68
-                textInputProps = { _TEXT_INPUT_PROPS } />
84
+                textInputProps = { textInputProps }
85
+                validateInput = { this._validateInput } />
69
         );
86
         );
70
     }
87
     }
71
 
88
 
100
 
117
 
101
         return false; // Do not hide.
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
 export default connect()(RoomLockPrompt);
144
 export default connect()(RoomLockPrompt);

読み込み中…
キャンセル
保存