From 094ecfbbfda7bf75bd1f7dbcef1ade98c850080e Mon Sep 17 00:00:00 2001 From: Ramon Souza Date: Wed, 30 Jun 2021 11:29:03 -0300 Subject: [PATCH 1/2] fix reconnection crash --- .../imports/api/users-settings/server/publishers.js | 2 +- .../imports/ui/components/app/container.jsx | 11 ++++++----- .../components-data/chat-context/adapter.jsx | 2 +- .../components-data/users-context/context.jsx | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/bigbluebutton-html5/imports/api/users-settings/server/publishers.js b/bigbluebutton-html5/imports/api/users-settings/server/publishers.js index cd7c68e73c..2b828e2b3d 100644 --- a/bigbluebutton-html5/imports/api/users-settings/server/publishers.js +++ b/bigbluebutton-html5/imports/api/users-settings/server/publishers.js @@ -16,7 +16,7 @@ function userSettings() { const currentUser = User.findOne({ userId, meetingId }); - if (currentUser && currentUser.breakoutProps.isBreakoutUser) { + if (currentUser && currentUser?.breakoutProps?.isBreakoutUser) { const { parentId } = currentUser.breakoutProps; const [externalId] = currentUser.extId.split('-'); diff --git a/bigbluebutton-html5/imports/ui/components/app/container.jsx b/bigbluebutton-html5/imports/ui/components/app/container.jsx index 204a6c26e7..784de29afd 100755 --- a/bigbluebutton-html5/imports/ui/components/app/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/app/container.jsx @@ -56,17 +56,18 @@ const AppContainer = (props) => { navbar, actionsbar, media, + currentUserId, ...otherProps } = props; - return ( + return currentUserId ? - ); + : null }; const currentUserEmoji = currentUser => (currentUser ? { @@ -95,7 +96,7 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) { fields: { publishedPoll: 1, voiceProp: 1, randomlySelectedUser: 1 } }); const { publishedPoll, voiceProp, randomlySelectedUser } = currentMeeting; - if (!currentUser.approved) { + if (currentUser && !currentUser.approved) { baseControls.updateLoadingState(intl.formatMessage(intlMessages.waitingApprovalMessage)); } @@ -122,8 +123,8 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) startBandwidthMonitoring, handleNetworkConnection: () => updateNavigatorConnection(navigator.connection), randomlySelectedUser, - currentUserId: currentUser.userId, - isPresenter: currentUser.presenter, + currentUserId: currentUser?.userId, + isPresenter: currentUser?.presenter, isLargeFont: Session.get('isLargeFont') }; })(AppContainer))); diff --git a/bigbluebutton-html5/imports/ui/components/components-data/chat-context/adapter.jsx b/bigbluebutton-html5/imports/ui/components/components-data/chat-context/adapter.jsx index db9c29bb66..29bb43ba04 100644 --- a/bigbluebutton-html5/imports/ui/components/components-data/chat-context/adapter.jsx +++ b/bigbluebutton-html5/imports/ui/components/components-data/chat-context/adapter.jsx @@ -89,7 +89,7 @@ const Adapter = () => { /* needed to prevent an issue with dupĺicated messages when user role is changed more info: https://github.com/bigbluebutton/bigbluebutton/issues/11842 */ useEffect(() => { - if (users[Auth.meetingID]) { + if (users[Auth.meetingID] && users[Auth.meetingID][Auth.userID]) { if (currentUserData?.role !== users[Auth.meetingID][Auth.userID].role) { prevUserData = currentUserData; } diff --git a/bigbluebutton-html5/imports/ui/components/components-data/users-context/context.jsx b/bigbluebutton-html5/imports/ui/components/components-data/users-context/context.jsx index 544c57860f..ff3c50bc96 100644 --- a/bigbluebutton-html5/imports/ui/components/components-data/users-context/context.jsx +++ b/bigbluebutton-html5/imports/ui/components/components-data/users-context/context.jsx @@ -55,7 +55,7 @@ const reducer = (state, action) => { // USER PERSISTENT DATA case ACTIONS.ADDED_USER_PERSISTENT_DATA: { const { user } = action.value; - if (state[user.meetingId][user.userId]) { + if (state[user.meetingId] && state[user.meetingId][user.userId]) { return state; } From 36c9176b3dbe72714c98fc9e52b0141f0fabcf5a Mon Sep 17 00:00:00 2001 From: Ramon Souza Date: Fri, 2 Jul 2021 10:33:17 -0300 Subject: [PATCH 2/2] always get token info from current connectionId --- bigbluebutton-html5/imports/ui/components/app/container.jsx | 1 + bigbluebutton-html5/imports/ui/services/auth/index.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/bigbluebutton-html5/imports/ui/components/app/container.jsx b/bigbluebutton-html5/imports/ui/components/app/container.jsx index 784de29afd..2670571cb2 100755 --- a/bigbluebutton-html5/imports/ui/components/app/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/app/container.jsx @@ -65,6 +65,7 @@ const AppContainer = (props) => { navbar={navbar} actionsbar={actionsbar} media={media} + currentUserId={currentUserId} {...otherProps} /> : null diff --git a/bigbluebutton-html5/imports/ui/services/auth/index.js b/bigbluebutton-html5/imports/ui/services/auth/index.js index ea98f8cb26..3790d29142 100755 --- a/bigbluebutton-html5/imports/ui/services/auth/index.js +++ b/bigbluebutton-html5/imports/ui/services/auth/index.js @@ -231,7 +231,11 @@ class Auth { Tracker.autorun((c) => { computation = c; - const authenticationTokenValidation = AuthTokenValidation.findOne({}, { sort: { updatedAt: -1 } }); + const selector = { + connectionId: Meteor.connection._lastSessionId, + }; + + const authenticationTokenValidation = AuthTokenValidation.findOne(selector); if (!authenticationTokenValidation) return;