Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
fix(jaas) do not redirect to plan limit page on auth errors (#9746)
Avram Tudor49a73ac44657
diff --git a/connection.js b/connection.jsindex f6544e68e3..1f8bd1df58 100644--- a/connection.js+++ b/connection.js@@ -17,6 +17,7 @@ import {JitsiConnectionErrors,JitsiConnectionEvents} from './react/features/base/lib-jitsi-meet';+import { getCustomerDetails } from './react/features/jaas/actions.any';import { isVpaasMeeting, getJaasJWT } from './react/features/jaas/functions';import { setPrejoinDisplayNameRequired } from './react/features/prejoin/actions';const logger = Logger.getLogger(__filename);@@ -90,9 +91,13 @@ export async function connect(id, password, roomName) {let { jwt } = state['features/base/jwt'];const { iAmRecorder, iAmSipGateway } = state['features/base/config'];- if (!iAmRecorder && !iAmSipGateway && !jwt && isVpaasMeeting(state)) {- jwt = await getJaasJWT(state);- APP.store.dispatch(setJWT(jwt));+ if (!iAmRecorder && !iAmSipGateway && isVpaasMeeting(state)) {+ await APP.store.dispatch(getCustomerDetails());++ if (!jwt) {+ jwt = await getJaasJWT(state);+ APP.store.dispatch(setJWT(jwt));+ }}// Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumptiondiff --git a/react/features/jaas/actions.any.js b/react/features/jaas/actions.any.jsnew file mode 100644index 0000000000..aa7d8a33c9--- /dev/null+++ b/react/features/jaas/actions.any.js@@ -0,0 +1,46 @@+// @flow++import { SET_DETAILS } from './actionTypes';+import { getVpaasTenant, sendGetDetailsRequest } from './functions';+import logger from './logger';++/**+ * Action used to set the jaas customer details in store.+ *+ * @param {Object} details - The customer details object.+ * @returns {Object}+ */+function setCustomerDetails(details) {+ return {+ type: SET_DETAILS,+ payload: details+ };+}++/**+ * Sends a request for retrieving jaas customer details.+ *+ * @returns {Function}+ */+export function getCustomerDetails() {+ return async function(dispatch: Function, getState: Function) {+ const state = getState();+ const baseUrl = state['features/base/config'].jaasActuatorUrl || 'https://api-vo-pilot.jitsi.net/jaas-actuator';+ const appId = getVpaasTenant(state);++ const shouldSendRequest = Boolean(baseUrl && appId);++ if (shouldSendRequest) {+ try {+ const details = await sendGetDetailsRequest({+ appId,+ baseUrl+ });++ dispatch(setCustomerDetails(details));+ } catch (err) {+ logger.error('Could not send request', err);+ }+ }+ };+}diff --git a/react/features/jaas/actions.web.js b/react/features/jaas/actions.web.jsindex ec8bb3690a..b6315e13d1 100644--- a/react/features/jaas/actions.web.js+++ b/react/features/jaas/actions.web.js@@ -2,55 +2,8 @@import { openDialog } from '../base/dialog';-import { SET_DETAILS } from './actionTypes';import { PremiumFeatureDialog } from './components';-import { VPAAS_TENANT_PREFIX } from './constants';-import { getVpaasTenant, isFeatureDisabled, sendGetDetailsRequest } from './functions';-import logger from './logger';--/**- * Action used to set the jaas customer details in store.- *- * @param {Object} details - The customer details object.- * @returns {Object}- */-function setCustomerDetails(details) {- return {- type: SET_DETAILS,- payload: details- };-}--/**- * Sends a request for retrieving jaas customer details.- *- * @returns {Function}- */-export function getCustomerDetails() {- return async function(dispatch: Function, getState: Function) {- const state = getState();- const baseUrl = state['features/base/config'].jaasActuatorUrl;- const jwt = state['features/base/jwt'].jwt;- const appId = getVpaasTenant(state).replace(VPAAS_TENANT_PREFIX, '');-- const shouldSendRequest = Boolean(baseUrl && jwt && appId);-- if (shouldSendRequest) {- try {- const details = await sendGetDetailsRequest({- baseUrl,- jwt,- appId- });-- dispatch(setCustomerDetails(details));- } catch (err) {- logger.error('Could not send request', err);- }- }- };-}-+import { isFeatureDisabled } from './functions';/*** Shows a dialog prompting users to upgrade, if requested feature is disabled.diff --git a/react/features/jaas/functions.js b/react/features/jaas/functions.jsindex 1984a81852..ba7cc79aab 100644--- a/react/features/jaas/functions.js+++ b/react/features/jaas/functions.js@@ -54,24 +54,16 @@ export function isVpaasMeeting(state: Object) {* @param {Object} reqData - The request info.* @param {string} reqData.appId - The client appId.* @param {string} reqData.baseUrl - The base url for the request.- * @param {string} reqData.jwt - The JWT token.* @returns {void}*/-export async function sendGetDetailsRequest({ appId, baseUrl, jwt }: {+export async function sendGetDetailsRequest({ appId, baseUrl }: {appId: string,baseUrl: string,- jwt: string,}) {- const fullUrl = `${baseUrl}/v1/customers/${encodeURIComponent(appId)}`;- const headers = {- 'Authorization': `Bearer ${jwt}`- };+ const fullUrl = `${baseUrl}/v1/public/tenants/${encodeURIComponent(appId)}`;try {- const res = await fetch(fullUrl, {- method: 'GET',- headers- });+ const res = await fetch(fullUrl);if (res.ok) {return res.json();diff --git a/react/features/jaas/middleware.web.js b/react/features/jaas/middleware.web.jsindex 4fa4adccd1..bd7fc9bfd0 100644--- a/react/features/jaas/middleware.web.js+++ b/react/features/jaas/middleware.web.js@@ -1,14 +1,9 @@import { redirectToStaticPage } from '../app/actions';-import { CONFERENCE_JOINED } from '../base/conference/actionTypes';-import { CONNECTION_FAILED } from '../base/connection';-import { JitsiConnectionErrors } from '../base/lib-jitsi-meet';import { MiddlewareRegistry } from '../base/redux';import { SET_DETAILS } from './actionTypes';-import { getCustomerDetails } from './actions';import { STATUSES } from './constants';-import { isVpaasMeeting } from './functions';/*** The redux middleware for jaas.@@ -18,27 +13,6 @@ import { isVpaasMeeting } from './functions';*/MiddlewareRegistry.register(store => next => async action => {switch (action.type) {- case CONFERENCE_JOINED: {- store.dispatch(getCustomerDetails());- break;- }-- case CONNECTION_FAILED: {- const { error } = action;-- if (!isVpaasMeeting(store.getState()) || !error) {- break;- }-- if (error.name === JitsiConnectionErrors.PASSWORD_REQUIRED) {- if (error.message !== 'could not obtain public key') {- break;- }-- store.dispatch(redirectToStaticPage('/static/planLimit.html'));- }- break;- }case SET_DETAILS: {const { status } = action.payload;