浏览代码

fix(jaas) do not redirect to plan limit page on auth errors (#9746)

master
Avram Tudor 3 年前
父节点
当前提交
49a73ac446
没有帐户链接到提交者的电子邮件

+ 8
- 3
connection.js 查看文件

@@ -17,6 +17,7 @@ import {
17 17
     JitsiConnectionErrors,
18 18
     JitsiConnectionEvents
19 19
 } from './react/features/base/lib-jitsi-meet';
20
+import { getCustomerDetails } from './react/features/jaas/actions.any';
20 21
 import { isVpaasMeeting, getJaasJWT } from './react/features/jaas/functions';
21 22
 import { setPrejoinDisplayNameRequired } from './react/features/prejoin/actions';
22 23
 const logger = Logger.getLogger(__filename);
@@ -90,9 +91,13 @@ export async function connect(id, password, roomName) {
90 91
     let { jwt } = state['features/base/jwt'];
91 92
     const { iAmRecorder, iAmSipGateway } = state['features/base/config'];
92 93
 
93
-    if (!iAmRecorder && !iAmSipGateway && !jwt && isVpaasMeeting(state)) {
94
-        jwt = await getJaasJWT(state);
95
-        APP.store.dispatch(setJWT(jwt));
94
+    if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {
95
+        await APP.store.dispatch(getCustomerDetails());
96
+
97
+        if (!jwt) {
98
+            jwt = await getJaasJWT(state);
99
+            APP.store.dispatch(setJWT(jwt));
100
+        }
96 101
     }
97 102
 
98 103
     // Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption

+ 46
- 0
react/features/jaas/actions.any.js 查看文件

@@ -0,0 +1,46 @@
1
+// @flow
2
+
3
+import { SET_DETAILS } from './actionTypes';
4
+import { getVpaasTenant, sendGetDetailsRequest } from './functions';
5
+import logger from './logger';
6
+
7
+/**
8
+ * Action used to set the jaas customer details in store.
9
+ *
10
+ * @param {Object} details - The customer details object.
11
+ * @returns {Object}
12
+ */
13
+function setCustomerDetails(details) {
14
+    return {
15
+        type: SET_DETAILS,
16
+        payload: details
17
+    };
18
+}
19
+
20
+/**
21
+ * Sends a request for retrieving jaas customer details.
22
+ *
23
+ * @returns {Function}
24
+ */
25
+export function getCustomerDetails() {
26
+    return async function(dispatch: Function, getState: Function) {
27
+        const state = getState();
28
+        const baseUrl = state['features/base/config'].jaasActuatorUrl || 'https://api-vo-pilot.jitsi.net/jaas-actuator';
29
+        const appId = getVpaasTenant(state);
30
+
31
+        const shouldSendRequest = Boolean(baseUrl && appId);
32
+
33
+        if (shouldSendRequest) {
34
+            try {
35
+                const details = await sendGetDetailsRequest({
36
+                    appId,
37
+                    baseUrl
38
+                });
39
+
40
+                dispatch(setCustomerDetails(details));
41
+            } catch (err) {
42
+                logger.error('Could not send request', err);
43
+            }
44
+        }
45
+    };
46
+}

+ 1
- 48
react/features/jaas/actions.web.js 查看文件

@@ -2,55 +2,8 @@
2 2
 
3 3
 import { openDialog } from '../base/dialog';
4 4
 
5
-import { SET_DETAILS } from './actionTypes';
6 5
 import { PremiumFeatureDialog } from './components';
7
-import { VPAAS_TENANT_PREFIX } from './constants';
8
-import { getVpaasTenant, isFeatureDisabled, sendGetDetailsRequest } from './functions';
9
-import logger from './logger';
10
-
11
-/**
12
- * Action used to set the jaas customer details in store.
13
- *
14
- * @param {Object} details - The customer details object.
15
- * @returns {Object}
16
- */
17
-function setCustomerDetails(details) {
18
-    return {
19
-        type: SET_DETAILS,
20
-        payload: details
21
-    };
22
-}
23
-
24
-/**
25
- * Sends a request for retrieving jaas customer details.
26
- *
27
- * @returns {Function}
28
- */
29
-export function getCustomerDetails() {
30
-    return async function(dispatch: Function, getState: Function) {
31
-        const state = getState();
32
-        const baseUrl = state['features/base/config'].jaasActuatorUrl;
33
-        const jwt = state['features/base/jwt'].jwt;
34
-        const appId = getVpaasTenant(state).replace(VPAAS_TENANT_PREFIX, '');
35
-
36
-        const shouldSendRequest = Boolean(baseUrl && jwt && appId);
37
-
38
-        if (shouldSendRequest) {
39
-            try {
40
-                const details = await sendGetDetailsRequest({
41
-                    baseUrl,
42
-                    jwt,
43
-                    appId
44
-                });
45
-
46
-                dispatch(setCustomerDetails(details));
47
-            } catch (err) {
48
-                logger.error('Could not send request', err);
49
-            }
50
-        }
51
-    };
52
-}
53
-
6
+import { isFeatureDisabled } from './functions';
54 7
 
55 8
 /**
56 9
  * Shows a dialog prompting users to upgrade, if requested feature is disabled.

+ 3
- 11
react/features/jaas/functions.js 查看文件

@@ -54,24 +54,16 @@ export function isVpaasMeeting(state: Object) {
54 54
  * @param {Object} reqData - The request info.
55 55
  * @param {string} reqData.appId - The client appId.
56 56
  * @param {string} reqData.baseUrl - The base url for the request.
57
- * @param {string} reqData.jwt - The JWT token.
58 57
  * @returns {void}
59 58
  */
60
-export async function sendGetDetailsRequest({ appId, baseUrl, jwt }: {
59
+export async function sendGetDetailsRequest({ appId, baseUrl }: {
61 60
     appId: string,
62 61
     baseUrl: string,
63
-    jwt: string,
64 62
 }) {
65
-    const fullUrl = `${baseUrl}/v1/customers/${encodeURIComponent(appId)}`;
66
-    const headers = {
67
-        'Authorization': `Bearer ${jwt}`
68
-    };
63
+    const fullUrl = `${baseUrl}/v1/public/tenants/${encodeURIComponent(appId)}`;
69 64
 
70 65
     try {
71
-        const res = await fetch(fullUrl, {
72
-            method: 'GET',
73
-            headers
74
-        });
66
+        const res = await fetch(fullUrl);
75 67
 
76 68
         if (res.ok) {
77 69
             return res.json();

+ 0
- 26
react/features/jaas/middleware.web.js 查看文件

@@ -1,14 +1,9 @@
1 1
 import { redirectToStaticPage } from '../app/actions';
2
-import { CONFERENCE_JOINED } from '../base/conference/actionTypes';
3
-import { CONNECTION_FAILED } from '../base/connection';
4
-import { JitsiConnectionErrors } from '../base/lib-jitsi-meet';
5 2
 import { MiddlewareRegistry } from '../base/redux';
6 3
 
7 4
 
8 5
 import { SET_DETAILS } from './actionTypes';
9
-import { getCustomerDetails } from './actions';
10 6
 import { STATUSES } from './constants';
11
-import { isVpaasMeeting } from './functions';
12 7
 
13 8
 /**
14 9
  * The redux middleware for jaas.
@@ -18,27 +13,6 @@ import { isVpaasMeeting } from './functions';
18 13
  */
19 14
 MiddlewareRegistry.register(store => next => async action => {
20 15
     switch (action.type) {
21
-    case CONFERENCE_JOINED: {
22
-        store.dispatch(getCustomerDetails());
23
-        break;
24
-    }
25
-
26
-    case CONNECTION_FAILED: {
27
-        const { error } = action;
28
-
29
-        if (!isVpaasMeeting(store.getState()) || !error) {
30
-            break;
31
-        }
32
-
33
-        if (error.name === JitsiConnectionErrors.PASSWORD_REQUIRED) {
34
-            if (error.message !== 'could not obtain public key') {
35
-                break;
36
-            }
37
-
38
-            store.dispatch(redirectToStaticPage('/static/planLimit.html'));
39
-        }
40
-        break;
41
-    }
42 16
     case SET_DETAILS: {
43 17
         const { status } = action.payload;
44 18
 

正在加载...
取消
保存