Browse Source

feat(authentication): group config options inside an object param

factor2
Calin-Teodor 1 year ago
parent
commit
b09574f62f

+ 8
- 6
react/features/app/actions.any.ts View File

@@ -128,14 +128,16 @@ export function maybeRedirectToTokenAuthUrl(
128 128
         const { tenant } = parseURIString(locationURL.href) || {};
129 129
 
130 130
         getTokenAuthUrl(
131
-            audioMuted,
132
-            audioOnlyEnabled || startAudioOnly,
133 131
             config,
134
-            room,
135
-            tenant,
136
-            true,
137 132
             locationURL,
138
-            videoMuted
133
+            {
134
+                audioMuted,
135
+                audioOnlyEnabled: audioOnlyEnabled || startAudioOnly,
136
+                skipPrejoin: true,
137
+                videoMuted
138
+            },
139
+            room,
140
+            tenant
139 141
         )
140 142
             .then((tokenAuthServiceUrl: string | undefined) => {
141 143
                 if (!tokenAuthServiceUrl) {

+ 12
- 1
react/features/app/getRouteToRender.web.ts View File

@@ -57,7 +57,18 @@ function _getWebConferenceRoute(state: IReduxState) {
57 57
         const { tenant } = parseURIString(locationURL.href) || {};
58 58
         const { startAudioOnly } = config;
59 59
 
60
-        return getTokenAuthUrl(false, startAudioOnly, config, room, tenant, false, locationURL, false)
60
+        return getTokenAuthUrl(
61
+            config,
62
+            locationURL,
63
+            {
64
+                audioMuted: false,
65
+                audioOnlyEnabled: startAudioOnly,
66
+                skipPrejoin: false,
67
+                videoMuted: false
68
+            },
69
+            room,
70
+            tenant
71
+        )
61 72
             .then((url: string | undefined) => {
62 73
                 route.href = url;
63 74
 

+ 23
- 12
react/features/authentication/functions.any.ts View File

@@ -13,30 +13,41 @@ export const isTokenAuthEnabled = (config: IConfig): boolean =>
13 13
 /**
14 14
  * Returns the state that we can add as a parameter to the tokenAuthUrl.
15 15
  *
16
- * @param {boolean} audioMuted - Start conference with audio muted.
17
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
16
+ * @param {URL} locationURL - The location URL.
17
+ * @param {Object} options: - Config options {
18
+ *     audioMuted: boolean | undefined
19
+ *     audioOnlyEnabled: boolean | undefined,
20
+ *     skipPrejoin: boolean | undefined,
21
+ *     videoMuted: boolean | undefined
22
+ * }.
18 23
  * @param {string?} roomName - The room name.
19 24
  * @param {string?} tenant - The tenant name if any.
20
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
21
- * @param {URL} locationURL - The location URL.
22
- * @param {boolean} videoMuted - Start conference with video muted.
25
+ *
23 26
  * @returns {Object} The state object.
24 27
  */
25 28
 export const _getTokenAuthState = (
26
-        audioMuted: boolean | undefined = false,
27
-        audioOnlyEnabled: boolean | undefined = false,
28
-        roomName: string | undefined,
29
-        tenant: string | undefined,
30
-        skipPrejoin: boolean | undefined = false,
31 29
         locationURL: URL,
32
-        // eslint-disable-next-line max-params
33
-        videoMuted: boolean | undefined = false): object => {
30
+        options: {
31
+            audioMuted: boolean | undefined;
32
+            audioOnlyEnabled: boolean | undefined;
33
+            skipPrejoin: boolean | undefined;
34
+            videoMuted: boolean | undefined;
35
+        },
36
+        roomName: string | undefined,
37
+        tenant: string | undefined): object => {
34 38
     const state = {
35 39
         room: roomName,
36 40
         roomSafe: getBackendSafeRoomName(roomName),
37 41
         tenant
38 42
     };
39 43
 
44
+    const {
45
+        audioMuted = false,
46
+        audioOnlyEnabled = false,
47
+        skipPrejoin = false,
48
+        videoMuted = false
49
+    } = options;
50
+
40 51
     if (audioMuted) {
41 52
 
42 53
         // @ts-ignore

+ 31
- 18
react/features/authentication/functions.native.ts View File

@@ -13,29 +13,40 @@ export * from './functions.any';
13 13
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
14 14
  * argument to this method.
15 15
  *
16
- * @param {boolean} audioMuted - Start conference with audio muted.
17
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
18 16
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
19
- * @param {string} roomName - The name of the conference room for which the user will be authenticated.
20
- * @param {string} tenant - The name of the conference tenant.
21
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
22 17
  * @param {URL} locationURL - The location URL.
23
- * @param {boolean} videoMuted - Start conference with video muted.
18
+ * @param {Object} options:  - Config options {
19
+ *     audioMuted: boolean | undefined
20
+ *     audioOnlyEnabled: boolean | undefined,
21
+ *     skipPrejoin: boolean | undefined,
22
+ *     videoMuted: boolean | undefined
23
+ * }.
24
+ * @param {string?} roomName - The room name.
25
+ * @param {string?} tenant - The tenant name if any.
24 26
  *
25 27
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
26 28
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
27 29
  * constructed.
28 30
  */
29 31
 export const getTokenAuthUrl = (
30
-        audioMuted: boolean | undefined = false,
31
-        audioOnlyEnabled: boolean | undefined = false,
32 32
         config: IConfig,
33
-        roomName: string | undefined,
34
-        tenant: string | undefined,
35
-        skipPrejoin: boolean | undefined = false,
36 33
         locationURL: URL,
34
+        options: {
35
+            audioMuted: boolean | undefined;
36
+            audioOnlyEnabled: boolean | undefined;
37
+            skipPrejoin: boolean | undefined;
38
+            videoMuted: boolean | undefined;
39
+        },
40
+        roomName: string | undefined,
37 41
         // eslint-disable-next-line max-params
38
-        videoMuted: boolean | undefined = false): Promise<string | undefined> => {
42
+        tenant: string | undefined): Promise<string | undefined> => {
43
+
44
+    const {
45
+        audioMuted = false,
46
+        audioOnlyEnabled = false,
47
+        skipPrejoin = false,
48
+        videoMuted = false
49
+    } = options;
39 50
 
40 51
     let url = config.tokenAuthUrl;
41 52
 
@@ -45,13 +56,15 @@ export const getTokenAuthUrl = (
45 56
 
46 57
     if (url.indexOf('{state}')) {
47 58
         const state = _getTokenAuthState(
48
-            audioMuted,
49
-            audioOnlyEnabled,
50
-            roomName,
51
-            tenant,
52
-            skipPrejoin,
53 59
             locationURL,
54
-            videoMuted
60
+            {
61
+                audioMuted,
62
+                audioOnlyEnabled,
63
+                skipPrejoin,
64
+                videoMuted
65
+            },
66
+            roomName,
67
+            tenant
55 68
         );
56 69
 
57 70
         // Append ios=true or android=true to the token URL.

+ 32
- 19
react/features/authentication/functions.web.ts View File

@@ -31,29 +31,40 @@ function _cryptoRandom() {
31 31
  * '{room}' - name of the conference room passed as <tt>roomName</tt>
32 32
  * argument to this method.
33 33
  *
34
- * @param {boolean} audioMuted - Start conference with audio muted.
35
- * @param {boolean} audioOnlyEnabled - Join conference audio only.
36 34
  * @param {Object} config - Configuration state object from store. A URL pattern pointing to the login service.
37
- * @param {string} roomName - The name of the conference room for which the user will be authenticated.
38
- * @param {string} tenant - The name of the conference tenant.
39
- * @param {boolean} skipPrejoin - Whether to skip pre-join page.
40
- * @param {URL} locationURL - The current location URL.
41
- * @param {boolean} videoMuted - Start conference with video muted.
35
+ * @param {URL} locationURL - The location URL.
36
+ * @param {Object} options:  - Config options {
37
+ *     audioMuted: boolean | undefined
38
+ *     audioOnlyEnabled: boolean | undefined,
39
+ *     skipPrejoin: boolean | undefined,
40
+ *     videoMuted: boolean | undefined
41
+ * }.
42
+ * @param {string?} roomName - The room name.
43
+ * @param {string?} tenant - The tenant name if any.
42 44
  *
43 45
  * @returns {Promise<string|undefined>} - The URL pointing to JWT login service or
44 46
  * <tt>undefined</tt> if the pattern stored in config is not a string and the URL can not be
45 47
  * constructed.
46 48
  */
47 49
 export const getTokenAuthUrl = (
48
-        audioMuted: boolean | undefined = false,
49
-        audioOnlyEnabled: boolean | undefined = false,
50 50
         config: IConfig,
51
-        roomName: string | undefined,
52
-        tenant: string | undefined,
53
-        skipPrejoin: boolean | undefined = false,
54 51
         locationURL: URL,
52
+        options: {
53
+            audioMuted: boolean | undefined;
54
+            audioOnlyEnabled: boolean | undefined;
55
+            skipPrejoin: boolean | undefined;
56
+            videoMuted: boolean | undefined;
57
+        },
58
+        roomName: string | undefined,
55 59
         // eslint-disable-next-line max-params
56
-        videoMuted: boolean | undefined = false): Promise<string | undefined> => {
60
+        tenant: string | undefined): Promise<string | undefined> => {
61
+
62
+    const {
63
+        audioMuted = false,
64
+        audioOnlyEnabled = false,
65
+        skipPrejoin = false,
66
+        videoMuted = false
67
+    } = options;
57 68
 
58 69
     let url = config.tokenAuthUrl;
59 70
 
@@ -63,13 +74,15 @@ export const getTokenAuthUrl = (
63 74
 
64 75
     if (url.indexOf('{state}')) {
65 76
         const state = _getTokenAuthState(
66
-            audioMuted,
67
-            audioOnlyEnabled,
68
-            roomName,
69
-            tenant,
70
-            skipPrejoin,
71 77
             locationURL,
72
-            videoMuted
78
+            {
79
+                audioMuted,
80
+                audioOnlyEnabled,
81
+                skipPrejoin,
82
+                videoMuted
83
+            },
84
+            roomName,
85
+            tenant
73 86
         );
74 87
 
75 88
         if (browser.isElectron()) {

+ 12
- 1
react/features/authentication/middleware.ts View File

@@ -275,7 +275,18 @@ function _handleLogin({ dispatch, getState }: IStore) {
275 275
         return;
276 276
     }
277 277
 
278
-    getTokenAuthUrl(audioMuted, audioOnlyEnabled, config, room, tenant, true, locationURL, videoMuted)
278
+    getTokenAuthUrl(
279
+        config,
280
+        locationURL,
281
+        {
282
+            audioMuted,
283
+            audioOnlyEnabled,
284
+            skipPrejoin: true,
285
+            videoMuted
286
+        },
287
+        room,
288
+        tenant
289
+    )
279 290
         .then((tokenAuthServiceUrl: string | undefined) => {
280 291
             if (!tokenAuthServiceUrl) {
281 292
                 logger.warn('Cannot handle login, token service URL is not set');

Loading…
Cancel
Save