From 470937bf6f01571082b5afdfa5e6aa10fbf44b0c Mon Sep 17 00:00:00 2001 From: Tainan Felipe Date: Wed, 15 Mar 2023 10:18:31 -0300 Subject: [PATCH] Refactor: Migrate users for the Meteor 3.0 api --- .../imports/api/users/index.js | 2 +- .../api/users/server/handlers/changeRole.js | 4 +- .../api/users/server/handlers/emojiStatus.js | 4 +- .../server/handlers/presenterAssigned.js | 12 ++-- .../api/users/server/handlers/removeUser.js | 5 +- .../server/handlers/userInactivityInspect.js | 5 +- .../api/users/server/handlers/userJoined.js | 4 +- .../server/handlers/userLeftFlagUpdated.js | 4 +- .../users/server/handlers/userPinChanged.js | 5 +- .../server/handlers/validateAuthToken.js | 59 ++++++++++++------- .../users/server/methods/assignPresenter.js | 4 +- .../api/users/server/methods/setExitReason.js | 6 +- .../api/users/server/methods/setMobileUser.js | 4 +- .../users/server/methods/setSpeechLocale.js | 4 +- .../methods/setUserEffectiveConnectionType.js | 4 +- .../users/server/methods/userActivitySign.js | 4 +- .../api/users/server/methods/userLeaving.js | 6 +- .../users/server/methods/userLeftMeeting.js | 7 ++- .../users/server/methods/validateAuthToken.js | 4 +- .../users/server/modifiers/addDialInUser.js | 6 +- .../api/users/server/modifiers/addUser.js | 15 ++--- .../api/users/server/modifiers/changePin.js | 4 +- .../users/server/modifiers/changePresenter.js | 4 +- .../api/users/server/modifiers/changeRole.js | 4 +- .../api/users/server/modifiers/clearUsers.js | 6 +- .../users/server/modifiers/createDummyUser.js | 6 +- .../api/users/server/modifiers/removeUser.js | 21 +++---- .../modifiers/setConnectionIdAndAuthToken.js | 9 ++- .../api/users/server/modifiers/setMobile.js | 4 +- .../setUserEffectiveConnectionType.js | 8 ++- .../server/modifiers/setUserExitReason.js | 4 +- .../server/modifiers/updateSpeechLocale.js | 4 +- .../modifiers/updateUserConnectionId.js | 6 +- .../api/users/server/modifiers/userEjected.js | 6 +- .../server/modifiers/userInactivityInspect.js | 4 +- .../server/modifiers/userLeftFlagUpdated.js | 4 +- .../imports/api/users/server/publishers.js | 12 ++-- .../imports/ui/services/auth/index.js | 40 ++++++------- 38 files changed, 172 insertions(+), 142 deletions(-) diff --git a/bigbluebutton-html5/imports/api/users/index.js b/bigbluebutton-html5/imports/api/users/index.js index fcd49fe108..3b86729164 100644 --- a/bigbluebutton-html5/imports/api/users/index.js +++ b/bigbluebutton-html5/imports/api/users/index.js @@ -12,7 +12,7 @@ if (Meteor.isServer) { // 1. meetingId // 2. meetingId, userId // { connection: Meteor.isClient ? null : true } - Users._ensureIndex({ meetingId: 1, userId: 1 }); + Users.createIndexAsync({ meetingId: 1, userId: 1 }); } export default Users; diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/changeRole.js b/bigbluebutton-html5/imports/api/users/server/handlers/changeRole.js index 4148a8d94c..3039313c9b 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/changeRole.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/changeRole.js @@ -1,11 +1,11 @@ import { check } from 'meteor/check'; import changeRole from '/imports/api/users/server/modifiers/changeRole'; -export default function handleChangeRole(payload, meetingId) { +export default async function handleChangeRole(payload, meetingId) { check(payload.body, Object); check(meetingId, String); const { userId, role, changedBy } = payload.body; - changeRole(role, userId, meetingId, changedBy); + await changeRole(role, userId, meetingId, changedBy); } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/emojiStatus.js b/bigbluebutton-html5/imports/api/users/server/handlers/emojiStatus.js index 4aad07c6b4..4f67a4b405 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/emojiStatus.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/emojiStatus.js @@ -2,7 +2,7 @@ import Logger from '/imports/startup/server/logger'; import { check } from 'meteor/check'; import Users from '/imports/api/users'; -export default function handleEmojiStatus({ body }, meetingId) { +export default async function handleEmojiStatus({ body }, meetingId) { const { userId, emoji } = body; check(userId, String); @@ -21,7 +21,7 @@ export default function handleEmojiStatus({ body }, meetingId) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Assigned user emoji status ${emoji} id=${userId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js b/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js index 230ef99648..a84dc87b84 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/presenterAssigned.js @@ -18,10 +18,10 @@ function setPresenterInPodReqMsg(credentials) { // TODO-- switch to meetingId, e RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload); } -export default function handlePresenterAssigned({ body }, meetingId) { +export default async function handlePresenterAssigned({ body }, meetingId) { const { presenterId, assignedBy } = body; - changePresenter(true, presenterId, meetingId, assignedBy); + await changePresenter(true, presenterId, meetingId, assignedBy); const selector = { meetingId, @@ -34,7 +34,7 @@ export default function handlePresenterAssigned({ body }, meetingId) { podId: 'DEFAULT_PRESENTATION_POD', }; - const currentDefaultPod = PresentationPods.findOne(defaultPodSelector); + const currentDefaultPod = await PresentationPods.findOneAsync(defaultPodSelector); const setPresenterPayload = { meetingId, @@ -42,10 +42,10 @@ export default function handlePresenterAssigned({ body }, meetingId) { presenterId, }; - const prevPresenter = Users.findOne(selector); + const prevPresenter = await Users.findOneAsync(selector); if (prevPresenter) { - changePresenter(false, prevPresenter.userId, meetingId, assignedBy); + await changePresenter(false, prevPresenter.userId, meetingId, assignedBy); } /** @@ -55,7 +55,7 @@ export default function handlePresenterAssigned({ body }, meetingId) { */ if (currentDefaultPod.currentPresenterId !== presenterId) { - const presenterToBeAssigned = Users.findOne({ userId: presenterId }); + const presenterToBeAssigned = await Users.findOneAsync({ userId: presenterId }); if (!presenterToBeAssigned) setPresenterPayload.presenterId = ''; diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/removeUser.js b/bigbluebutton-html5/imports/api/users/server/handlers/removeUser.js index d710dc7e7e..60ba224216 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/removeUser.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/removeUser.js @@ -2,11 +2,12 @@ import { check } from 'meteor/check'; import removeUser from '../modifiers/removeUser'; -export default function handleRemoveUser({ body }, meetingId) { +export default async function handleRemoveUser({ body }, meetingId) { const { intId } = body; check(meetingId, String); check(intId, String); - return removeUser(body, meetingId); + const result = await removeUser(body, meetingId); + return result; } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/userInactivityInspect.js b/bigbluebutton-html5/imports/api/users/server/handlers/userInactivityInspect.js index cbe225f0bc..b94efe5a1d 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/userInactivityInspect.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/userInactivityInspect.js @@ -1,7 +1,7 @@ import { check } from 'meteor/check'; import userInactivityInspect from '../modifiers/userInactivityInspect'; -export default function handleUserInactivityInspect({ header, body }, meetingId) { +export default async function handleUserInactivityInspect({ header, body }, meetingId) { const { userId } = header; const { responseDelay } = body; @@ -9,6 +9,5 @@ export default function handleUserInactivityInspect({ header, body }, meetingId) check(responseDelay, Match.Integer); check(meetingId, String); - - userInactivityInspect(userId, responseDelay); + await userInactivityInspect(userId, responseDelay); } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/userJoined.js b/bigbluebutton-html5/imports/api/users/server/handlers/userJoined.js index 122503cf14..a0e237c031 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/userJoined.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/userJoined.js @@ -2,10 +2,10 @@ import { check } from 'meteor/check'; import addUser from '../modifiers/addUser'; -export default function handleUserJoined({ body }, meetingId) { +export default async function handleUserJoined({ body }, meetingId) { const user = body; check(user, Object); - addUser(meetingId, user); + await addUser(meetingId, user); } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/userLeftFlagUpdated.js b/bigbluebutton-html5/imports/api/users/server/handlers/userLeftFlagUpdated.js index 328e2fc78b..8041c10a6e 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/userLeftFlagUpdated.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/userLeftFlagUpdated.js @@ -2,12 +2,12 @@ import { check } from 'meteor/check'; import userLeftFlag from '../modifiers/userLeftFlagUpdated'; -export default function handleUserLeftFlag({ body }, meetingId) { +export default async function handleUserLeftFlag({ body }, meetingId) { const user = body; check(user, { intId: String, userLeftFlag: Boolean, }); - userLeftFlag(meetingId, user.intId, user.userLeftFlag); + await userLeftFlag(meetingId, user.intId, user.userLeftFlag); } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/userPinChanged.js b/bigbluebutton-html5/imports/api/users/server/handlers/userPinChanged.js index ea73b45a0e..15e8b30c69 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/userPinChanged.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/userPinChanged.js @@ -1,7 +1,7 @@ import { check } from 'meteor/check'; import changePin from '../modifiers/changePin'; -export default function handlePinAssigned({ body }, meetingId) { +export default async function handlePinAssigned({ body }, meetingId) { const { userId, pin, changedBy } = body; check(meetingId, String); @@ -9,5 +9,6 @@ export default function handlePinAssigned({ body }, meetingId) { check(pin, Boolean); check(changedBy, String); - return changePin(meetingId, userId, pin, changedBy); + const result = await changePin(meetingId, userId, pin, changedBy); + return result; } diff --git a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js index f24ec1afeb..f20686535a 100644 --- a/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js +++ b/bigbluebutton-html5/imports/api/users/server/handlers/validateAuthToken.js @@ -18,7 +18,7 @@ const clearOtherSessions = (sessionUserId, current = false) => { .forEach(i => serverSessions[i].close()); }; -export default function handleValidateAuthToken({ body }, meetingId) { +export default async function handleValidateAuthToken({ body }, meetingId) { const { userId, valid, @@ -42,56 +42,71 @@ export default function handleValidateAuthToken({ body }, meetingId) { if (pendingAuths.length === 0) return; if (!valid) { - pendingAuths.forEach( - (pendingAuth) => { + await Promise.all(pendingAuths.map( + async (pendingAuth) => { try { const { methodInvocationObject } = pendingAuth; const connectionId = methodInvocationObject.connection.id; - upsertValidationState(meetingId, userId, ValidationStates.INVALID, connectionId, reasonCode); + await upsertValidationState( + meetingId, + userId, + ValidationStates.INVALID, + connectionId, + reasonCode, + ); - // Schedule socket disconnection for this user, giving some time for client receiving the reason of disconnection - Meteor.setTimeout(() => { - methodInvocationObject.connection.close(); - }, 2000); - - Logger.info(`Closed connection ${connectionId} due to invalid auth token.`); + // Schedule socket disconnection for this user + // giving some time for client receiving the reason of disconnection + new Promise((resolve) => { + setTimeout(() => { + methodInvocationObject.connection.close(); + Logger.info(`Closed connection ${connectionId} due to invalid auth token.`); + resolve(); + }, 2000); + }); } catch (e) { Logger.error(`Error closing socket for meetingId '${meetingId}', userId '${userId}', authToken ${authToken}`); } }, - ); + )); return; } // Define user ID on connections - pendingAuths.forEach( - (pendingAuth) => { + await Promise.all(pendingAuths.map( + async (pendingAuth) => { const { methodInvocationObject } = pendingAuth; - /* Logic migrated from validateAuthToken method ( postponed to only run in case of success response ) - Begin */ + /* Logic migrated from validateAuthToken method + ( postponed to only run in case of success response ) - Begin */ const sessionId = `${meetingId}--${userId}`; methodInvocationObject.setUserId(sessionId); - const User = Users.findOne({ + const User = await Users.findOneAsync({ meetingId, userId, }); if (!User) { - createDummyUser(meetingId, userId, authToken); - }else{ - updateUserConnectionId(meetingId, userId, methodInvocationObject.connection.id); + await createDummyUser(meetingId, userId, authToken); + } else { + await updateUserConnectionId(meetingId, userId, methodInvocationObject.connection.id); } ClientConnections.add(sessionId, methodInvocationObject.connection); - upsertValidationState(meetingId, userId, ValidationStates.VALIDATED, methodInvocationObject.connection.id); + await upsertValidationState( + meetingId, + userId, + ValidationStates.VALIDATED, + methodInvocationObject.connection.id, + ); /* End of logic migrated from validateAuthToken */ }, - ); + )); const selector = { meetingId, @@ -99,7 +114,7 @@ export default function handleValidateAuthToken({ body }, meetingId) { clientType: 'HTML5', }; - const User = Users.findOne(selector); + const User = await Users.findOneAsync(selector); // If we dont find the user on our collection is a flash user and we can skip if (!User) return; @@ -121,7 +136,7 @@ export default function handleValidateAuthToken({ body }, meetingId) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { const sessionUserId = `${meetingId}-${userId}`; diff --git a/bigbluebutton-html5/imports/api/users/server/methods/assignPresenter.js b/bigbluebutton-html5/imports/api/users/server/methods/assignPresenter.js index f17e93c1f6..eb6284fdd3 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/assignPresenter.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/assignPresenter.js @@ -5,7 +5,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; import { extractCredentials } from '/imports/api/common/server/helpers'; -export default function assignPresenter(userId) { // TODO-- send username from client side +export default async function assignPresenter(userId) { // TODO-- send username from client side try { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; @@ -16,7 +16,7 @@ export default function assignPresenter(userId) { // TODO-- send username from c check(requesterUserId, String); check(userId, String); - const User = Users.findOne({ + const User = await Users.findOneAsync({ meetingId, userId, }); diff --git a/bigbluebutton-html5/imports/api/users/server/methods/setExitReason.js b/bigbluebutton-html5/imports/api/users/server/methods/setExitReason.js index b43bbf0b30..335a31ba39 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/setExitReason.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/setExitReason.js @@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger'; import { extractCredentials } from '/imports/api/common/server/helpers'; import setUserExitReason from '/imports/api/users/server/modifiers/setUserExitReason'; -export default function setExitReason(reason) { +export default async function setExitReason(reason) { try { const { meetingId, requesterUserId } = extractCredentials(this.userId); @@ -14,8 +14,8 @@ export default function setExitReason(reason) { check(requesterUserId, String); check(reason, String); - setUserExitReason(meetingId, requesterUserId, reason); + await setUserExitReason(meetingId, requesterUserId, reason); } catch (err) { Logger.error(`Exception while invoking method setExitReason ${err.stack}`); } -}; +} diff --git a/bigbluebutton-html5/imports/api/users/server/methods/setMobileUser.js b/bigbluebutton-html5/imports/api/users/server/methods/setMobileUser.js index fa6dd68dc1..09a426a83f 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/setMobileUser.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/setMobileUser.js @@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger'; import setMobile from '../modifiers/setMobile'; import { extractCredentials } from '/imports/api/common/server/helpers'; -export default function setMobileUser() { +export default async function setMobileUser() { try { const { meetingId, requesterUserId } = extractCredentials(this.userId); @@ -12,7 +12,7 @@ export default function setMobileUser() { Logger.verbose(`Mobile user ${requesterUserId} from meeting ${meetingId}`); - setMobile(meetingId, requesterUserId); + await setMobile(meetingId, requesterUserId); } catch (err) { Logger.error(`Exception while invoking method setMobileUser ${err.stack}`); } diff --git a/bigbluebutton-html5/imports/api/users/server/methods/setSpeechLocale.js b/bigbluebutton-html5/imports/api/users/server/methods/setSpeechLocale.js index 1fcada98c0..6945cdc0f6 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/setSpeechLocale.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/setSpeechLocale.js @@ -5,7 +5,7 @@ import { extractCredentials } from '/imports/api/common/server/helpers'; const LANGUAGES = Meteor.settings.public.app.audioCaptions.language.available; -export default function setSpeechLocale(locale) { +export default async function setSpeechLocale(locale) { try { const { meetingId, requesterUserId } = extractCredentials(this.userId); @@ -14,7 +14,7 @@ export default function setSpeechLocale(locale) { check(locale, String); if (LANGUAGES.includes(locale) || locale === '') { - updateSpeechLocale(meetingId, requesterUserId, locale); + await updateSpeechLocale(meetingId, requesterUserId, locale); } } catch (err) { Logger.error(`Exception while invoking method setSpeechLocale ${err.stack}`); diff --git a/bigbluebutton-html5/imports/api/users/server/methods/setUserEffectiveConnectionType.js b/bigbluebutton-html5/imports/api/users/server/methods/setUserEffectiveConnectionType.js index c6e9218f16..6826d66d1d 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/setUserEffectiveConnectionType.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/setUserEffectiveConnectionType.js @@ -5,7 +5,7 @@ import Logger from '/imports/startup/server/logger'; import { extractCredentials } from '/imports/api/common/server/helpers'; import setEffectiveConnectionType from '../modifiers/setUserEffectiveConnectionType'; -export default function setUserEffectiveConnectionType(effectiveConnectionType) { +export default async function setUserEffectiveConnectionType(effectiveConnectionType) { try { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; @@ -22,7 +22,7 @@ export default function setUserEffectiveConnectionType(effectiveConnectionType) effectiveConnectionType, }; - setEffectiveConnectionType(meetingId, requesterUserId, effectiveConnectionType); + await setEffectiveConnectionType(meetingId, requesterUserId, effectiveConnectionType); Logger.verbose('Updated user effective connection', { requesterUserId, effectiveConnectionType }); diff --git a/bigbluebutton-html5/imports/api/users/server/methods/userActivitySign.js b/bigbluebutton-html5/imports/api/users/server/methods/userActivitySign.js index 6d6b6f0b91..75722dbf04 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/userActivitySign.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/userActivitySign.js @@ -5,7 +5,7 @@ import Logger from '/imports/startup/server/logger'; import { extractCredentials } from '/imports/api/common/server/helpers'; import { check } from 'meteor/check'; -export default function userActivitySign() { +export default async function userActivitySign() { try { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; @@ -29,7 +29,7 @@ export default function userActivitySign() { }, }; - Users.update(selector, modifier); // TODO-- we should move this to a modifier + await Users.updateAsync(selector, modifier); // TODO-- we should move this to a modifier Logger.info(`User ${userId} sent a activity sign for meeting ${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js b/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js index bcd6ba35c9..b74044e3f4 100755 --- a/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/userLeaving.js @@ -6,7 +6,7 @@ import AuthTokenValidation from '/imports/api/auth-token-validation'; import Users from '/imports/api/users'; import ClientConnections from '/imports/startup/server/ClientConnections'; -export default function userLeaving(meetingId, userId, connectionId) { +export default async function userLeaving(meetingId, userId, connectionId) { try { const REDIS_CONFIG = Meteor.settings.private.redis; const CHANNEL = REDIS_CONFIG.channels.toAkkaApps; @@ -19,14 +19,14 @@ export default function userLeaving(meetingId, userId, connectionId) { userId, }; - const user = Users.findOne(selector); + const user = await Users.findOneAsync(selector); if (!user) { Logger.info(`Skipping userLeaving. Could not find ${userId} in ${meetingId}`); return; } - const auth = AuthTokenValidation.findOne({ + const auth = await AuthTokenValidation.findOneAsync({ meetingId, userId, }, { sort: { updatedAt: -1 } }); diff --git a/bigbluebutton-html5/imports/api/users/server/methods/userLeftMeeting.js b/bigbluebutton-html5/imports/api/users/server/methods/userLeftMeeting.js index b546d09da7..7d4e61669c 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/userLeftMeeting.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/userLeftMeeting.js @@ -5,7 +5,8 @@ import ClientConnections from '/imports/startup/server/ClientConnections'; import { check } from 'meteor/check'; import UsersPersistentData from '/imports/api/users-persistent-data'; -export default function userLeftMeeting() { // TODO-- spread the code to method/modifier/handler +export default async function userLeftMeeting() { + // TODO-- spread the code to method/modifier/handler try { // so we don't update the db in a method const { meetingId, requesterUserId } = extractCredentials(this.userId); @@ -18,10 +19,10 @@ export default function userLeftMeeting() { // TODO-- spread the code to method/ userId: requesterUserId, }; - const numberAffected = Users.update(selector, { $set: { loggedOut: true } }); + const numberAffected = await Users.updateAsync(selector, { $set: { loggedOut: true } }); if (numberAffected) { - UsersPersistentData.update(selector, { $set: { loggedOut: true } }); + await UsersPersistentData.updateAsync(selector, { $set: { loggedOut: true } }); Logger.info(`user left id=${requesterUserId} meeting=${meetingId}`); ClientConnections.removeClientConnection(this.userId, this.connection.id); } diff --git a/bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js b/bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js index 28a5300f4a..5b5a523629 100644 --- a/bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js +++ b/bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js @@ -9,7 +9,7 @@ const AUTH_TIMEOUT = 120000; async function validateAuthToken(meetingId, requesterUserId, requesterToken, externalId) { let setTimeoutRef = null; - const userValidation = await new Promise((res, rej) => { + const userValidation = await new Promise(async (res, rej) => { const observeFunc = (obj) => { if (obj.validationStatus === ValidationStates.VALIDATED) { clearTimeout(setTimeoutRef); @@ -43,7 +43,7 @@ async function validateAuthToken(meetingId, requesterUserId, requesterToken, ext // Store reference of methodInvocationObject ( to postpone the connection userId definition ) pendingAuthenticationsStore.add(meetingId, requesterUserId, requesterToken, this); - upsertValidationState( + await upsertValidationState( meetingId, requesterUserId, ValidationStates.VALIDATING, diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/addDialInUser.js b/bigbluebutton-html5/imports/api/users/server/modifiers/addDialInUser.js index ddba479d2e..5a1ce8f79b 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/addDialInUser.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/addDialInUser.js @@ -1,7 +1,7 @@ import { check } from 'meteor/check'; import addUser from '/imports/api/users/server/modifiers/addUser'; -export default function addDialInUser(meetingId, voiceUser) { +export default async function addDialInUser(meetingId, voiceUser) { check(meetingId, String); check(voiceUser, Object); @@ -26,6 +26,6 @@ export default function addDialInUser(meetingId, voiceUser) { pin: false, clientType: 'dial-in-user', }; - - return addUser(meetingId, voiceOnlyUser); + const user = await addUser(meetingId, voiceOnlyUser); + return user; } diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/addUser.js b/bigbluebutton-html5/imports/api/users/server/modifiers/addUser.js index 243f5cb522..de20cfb584 100755 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/addUser.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/addUser.js @@ -16,7 +16,7 @@ const COLOR_LIST = [ '#0d47a1', '#0277bd', '#01579b', ]; -export default function addUser(meetingId, userData) { +export default async function addUser(meetingId, userData) { const user = userData; check(meetingId, String); @@ -44,7 +44,7 @@ export default function addUser(meetingId, userData) { meetingId, userId, }; - const Meeting = Meetings.findOne({ meetingId }); + const Meeting = await Meetings.findOneAsync({ meetingId }); /* While the akka-apps dont generate a color we just pick one from a list based on the userId */ @@ -71,11 +71,12 @@ export default function addUser(meetingId, userData) { const modifier = { $set: userInfos, }; - addUserPsersistentData(userInfos); + await addUserPsersistentData(userInfos); // Only add an empty VoiceUser if there isn't one already and if the user coming in isn't a // dial-in user. We want to avoid overwriting good data - if (user.clientType !== 'dial-in-user' && !VoiceUsers.findOne({ meetingId, intId: userId })) { - addVoiceUser(meetingId, { + const voiceUser = await VoiceUsers.findOneAsync({ meetingId, intId: userId }); + if (user.clientType !== 'dial-in-user' && !voiceUser) { + await addVoiceUser(meetingId, { voiceUserId: '', intId: userId, callerName: user.name, @@ -94,14 +95,14 @@ export default function addUser(meetingId, userData) { * In some cases the user information is set after the presenter is set * causing the first moderator to join a meeting be marked as presenter: false */ - const partialUser = Users.findOne(selector); + const partialUser = await Users.findOneAsync(selector); if (partialUser?.presenter) { modifier.$set.presenter = true; } try { - const { insertedId } = Users.upsert(selector, modifier); + const { insertedId } = await Users.upsertAsync(selector, modifier); if (insertedId) { Logger.info(`Added user id=${userId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/changePin.js b/bigbluebutton-html5/imports/api/users/server/modifiers/changePin.js index 46ee4946c4..14f3a26eef 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/changePin.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/changePin.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function changePin(meetingId, userId, pin, changedBy) { +export default async function changePin(meetingId, userId, pin, changedBy) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function changePin(meetingId, userId, pin, changedBy) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Change pin=${pin} id=${userId} meeting=${meetingId} changedBy=${changedBy}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/changePresenter.js b/bigbluebutton-html5/imports/api/users/server/modifiers/changePresenter.js index 371fd939aa..bd2253b870 100755 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/changePresenter.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/changePresenter.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function changePresenter(presenter, userId, meetingId, changedBy) { +export default async function changePresenter(presenter, userId, meetingId, changedBy) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function changePresenter(presenter, userId, meetingId, changedBy) }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Changed presenter=${presenter} id=${userId} meeting=${meetingId}` diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/changeRole.js b/bigbluebutton-html5/imports/api/users/server/modifiers/changeRole.js index 1a98a7d40c..6dbfa93075 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/changeRole.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/changeRole.js @@ -2,7 +2,7 @@ import Logger from '/imports/startup/server/logger'; import updateRole from '/imports/api/users-persistent-data/server/modifiers/updateRole'; import Users from '/imports/api/users'; -export default function changeRole(role, userId, meetingId, changedBy) { +export default async function changeRole(role, userId, meetingId, changedBy) { const selector = { meetingId, userId, @@ -15,7 +15,7 @@ export default function changeRole(role, userId, meetingId, changedBy) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { updateRole(userId, meetingId, role); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/clearUsers.js b/bigbluebutton-html5/imports/api/users/server/modifiers/clearUsers.js index c6784ee564..4025469a08 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/clearUsers.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/clearUsers.js @@ -1,10 +1,10 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users/index'; -export default function clearUsers(meetingId) { +export default async function clearUsers(meetingId) { if (meetingId) { try { - const numberAffected = Users.remove({ meetingId }); + const numberAffected = await Users.removeAsync({ meetingId }); if (numberAffected) { Logger.info(`Cleared Users (${meetingId})`); @@ -14,7 +14,7 @@ export default function clearUsers(meetingId) { } } else { try { - const numberAffected = Users.remove({}); + const numberAffected = await Users.removeAsync({}); if (numberAffected) { Logger.info('Cleared Users (all)'); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/createDummyUser.js b/bigbluebutton-html5/imports/api/users/server/modifiers/createDummyUser.js index b5390ed728..32ff22e6ab 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/createDummyUser.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/createDummyUser.js @@ -3,12 +3,12 @@ import { check } from 'meteor/check'; import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function createDummyUser(meetingId, userId, authToken) { +export default async function createDummyUser(meetingId, userId, authToken) { check(meetingId, String); check(userId, String); check(authToken, String); - const User = Users.findOne({ meetingId, userId }); + const User = await Users.findOneAsync({ meetingId, userId }); if (User) { throw new Meteor.Error('existing-user', 'Tried to create a dummy user for an existing user'); } @@ -23,7 +23,7 @@ export default function createDummyUser(meetingId, userId, authToken) { }; try { - const insertedId = Users.insert(doc); + const insertedId = await Users.insertAsync(doc); if (insertedId) { Logger.info(`Created dummy user id=${userId} token=${authToken} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/removeUser.js b/bigbluebutton-html5/imports/api/users/server/modifiers/removeUser.js index 91494c2729..90f8816e42 100755 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/removeUser.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/removeUser.js @@ -24,7 +24,7 @@ const disconnectUser = (meetingId, userId) => { } }; -export default function removeUser(body, meetingId) { +export default async function removeUser(body, meetingId) { const { intId: userId, reasonCode } = body; check(meetingId, String); check(userId, String); @@ -39,30 +39,31 @@ export default function removeUser(body, meetingId) { // since the backend is supposed to update Mongo if ((process.env.BBB_HTML5_ROLE !== 'frontend')) { if (body.eject) { - userEjected(meetingId, userId, reasonCode); + await userEjected(meetingId, userId, reasonCode); } - setloggedOutStatus(userId, meetingId, true); - VideoStreams.remove({ meetingId, userId }); + await setloggedOutStatus(userId, meetingId, true); + await VideoStreams.removeAsync({ meetingId, userId }); - clearUserInfoForRequester(meetingId, userId); + await clearUserInfoForRequester(meetingId, userId); - const currentUser = UsersPersistentData.findOne({ userId, meetingId }); + const currentUser = await UsersPersistentData.findOneAsync({ userId, meetingId }); const hasMessages = currentUser?.shouldPersist?.hasMessages?.public || currentUser?.shouldPersist?.hasMessages?.private; const hasConnectionStatus = currentUser?.shouldPersist?.hasConnectionStatus; if (!hasMessages && !hasConnectionStatus) { - UsersPersistentData.remove(selector); + await UsersPersistentData.removeAsync(selector); } - Users.remove(selector); - clearVoiceUser(meetingId, userId); + await Users.removeAsync(selector); + await clearVoiceUser(meetingId, userId); } if (!process.env.BBB_HTML5_ROLE || process.env.BBB_HTML5_ROLE === 'frontend') { // Wait for user removal and then kill user connections and sessions const queryCurrentUser = Users.find(selector); - if (queryCurrentUser.count() === 0) { + const countUser = await queryCurrentUser.countAsync(); + if (countUser === 0) { disconnectUser(meetingId, userId); } else { const queryUserObserver = queryCurrentUser.observeChanges({ diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/setConnectionIdAndAuthToken.js b/bigbluebutton-html5/imports/api/users/server/modifiers/setConnectionIdAndAuthToken.js index aba77f300d..72002ff833 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/setConnectionIdAndAuthToken.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/setConnectionIdAndAuthToken.js @@ -2,7 +2,12 @@ import { check } from 'meteor/check'; import Users from '/imports/api/users'; import Logger from '/imports/startup/server/logger'; -export default function setConnectionIdAndAuthToken(meetingId, userId, connectionId, authToken) { +export default async function setConnectionIdAndAuthToken( + meetingId, + userId, + connectionId, + authToken, +) { check(meetingId, String); check(userId, String); check(authToken, String); @@ -21,7 +26,7 @@ export default function setConnectionIdAndAuthToken(meetingId, userId, connectio }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Updated connectionId and authToken user=${userId} connectionId=${connectionId} meeting=${meetingId} authToken=${authToken}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/setMobile.js b/bigbluebutton-html5/imports/api/users/server/modifiers/setMobile.js index 357cb68282..1634d110ec 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/setMobile.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/setMobile.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function setMobile(meetingId, userId) { +export default async function setMobile(meetingId, userId) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function setMobile(meetingId, userId) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Assigned mobile user id=${userId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/setUserEffectiveConnectionType.js b/bigbluebutton-html5/imports/api/users/server/modifiers/setUserEffectiveConnectionType.js index d9888ced73..8f926cafed 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/setUserEffectiveConnectionType.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/setUserEffectiveConnectionType.js @@ -2,7 +2,11 @@ import { check } from 'meteor/check'; import Users from '/imports/api/users'; import Logger from '/imports/startup/server/logger'; -export default function setUserEffectiveConnectionType(meetingId, userId, effectiveConnectionType) { +export default async function setUserEffectiveConnectionType( + meetingId, + userId, + effectiveConnectionType, +) { check(meetingId, String); check(userId, String); check(effectiveConnectionType, String); @@ -20,7 +24,7 @@ export default function setUserEffectiveConnectionType(meetingId, userId, effect }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Updated user ${userId} effective connection to ${effectiveConnectionType} in meeting ${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/setUserExitReason.js b/bigbluebutton-html5/imports/api/users/server/modifiers/setUserExitReason.js index c24f34002d..d5e41dffb1 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/setUserExitReason.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/setUserExitReason.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function setUserExitReason(meetingId, userId, reason) { +export default async function setUserExitReason(meetingId, userId, reason) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function setUserExitReason(meetingId, userId, reason) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Set exit reason userId=${userId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/updateSpeechLocale.js b/bigbluebutton-html5/imports/api/users/server/modifiers/updateSpeechLocale.js index f0cc639fad..cad50ca9d1 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/updateSpeechLocale.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/updateSpeechLocale.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function updateSpeechLocale(meetingId, userId, locale) { +export default async function updateSpeechLocale(meetingId, userId, locale) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function updateSpeechLocale(meetingId, userId, locale) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Updated speech locale=${locale} userId=${userId} meetingId=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/updateUserConnectionId.js b/bigbluebutton-html5/imports/api/users/server/modifiers/updateUserConnectionId.js index 2d01e33022..aeda50b2cb 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/updateUserConnectionId.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/updateUserConnectionId.js @@ -2,7 +2,7 @@ import { check } from 'meteor/check'; import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function updateUserConnectionId(meetingId, userId, connectionId) { +export default async function updateUserConnectionId(meetingId, userId, connectionId) { check(meetingId, String); check(userId, String); check(connectionId, String); @@ -16,11 +16,11 @@ export default function updateUserConnectionId(meetingId, userId, connectionId) }, }; - const User = Users.findOne(selector); + const User = await Users.findOneAsync(selector); if (User) { try { - const updated = Users.update(selector, modifier); + const updated = await Users.updateAsync(selector, modifier); if (updated) { Logger.info(`Updated connection user=${userId} connectionid=${connectionId} meeting=${meetingId}`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/userEjected.js b/bigbluebutton-html5/imports/api/users/server/modifiers/userEjected.js index 95a8c465cc..c06de19ebe 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/userEjected.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/userEjected.js @@ -3,7 +3,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; import clearUserInfoForRequester from '/imports/api/users-infos/server/modifiers/clearUserInfoForRequester'; -export default function userEjected(meetingId, userId, ejectedReason) { +export default async function userEjected(meetingId, userId, ejectedReason) { check(meetingId, String); check(userId, String); check(ejectedReason, String); @@ -21,10 +21,10 @@ export default function userEjected(meetingId, userId, ejectedReason) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { - clearUserInfoForRequester(meetingId, userId); + await clearUserInfoForRequester(meetingId, userId); Logger.info(`Ejected user id=${userId} meeting=${meetingId} reason=${ejectedReason}`); } } catch (err) { diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/userInactivityInspect.js b/bigbluebutton-html5/imports/api/users/server/modifiers/userInactivityInspect.js index eb35a707ab..f709d6d4b0 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/userInactivityInspect.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/userInactivityInspect.js @@ -2,7 +2,7 @@ import { check } from 'meteor/check'; import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function userInactivityInspect(userId, responseDelay) { +export default async function userInactivityInspect(userId, responseDelay) { check(userId, String); check(responseDelay, Match.Integer); @@ -19,7 +19,7 @@ export default function userInactivityInspect(userId, responseDelay) { }; try { - const { numberAffected } = Users.update(selector, modifier); + const { numberAffected } = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Updated user ${userId} with inactivity inspect`); diff --git a/bigbluebutton-html5/imports/api/users/server/modifiers/userLeftFlagUpdated.js b/bigbluebutton-html5/imports/api/users/server/modifiers/userLeftFlagUpdated.js index 361d80f766..51e0f2253d 100644 --- a/bigbluebutton-html5/imports/api/users/server/modifiers/userLeftFlagUpdated.js +++ b/bigbluebutton-html5/imports/api/users/server/modifiers/userLeftFlagUpdated.js @@ -1,7 +1,7 @@ import Logger from '/imports/startup/server/logger'; import Users from '/imports/api/users'; -export default function userLeftFlagUpdated(meetingId, userId, left) { +export default async function userLeftFlagUpdated(meetingId, userId, left) { const selector = { meetingId, userId, @@ -14,7 +14,7 @@ export default function userLeftFlagUpdated(meetingId, userId, left) { }; try { - const numberAffected = Users.update(selector, modifier); + const numberAffected = await Users.updateAsync(selector, modifier); if (numberAffected) { Logger.info(`Updated user ${userId} with left flag as ${left} in meeting ${meetingId}`); } diff --git a/bigbluebutton-html5/imports/api/users/server/publishers.js b/bigbluebutton-html5/imports/api/users/server/publishers.js index c9dec9ec32..562b40b98b 100644 --- a/bigbluebutton-html5/imports/api/users/server/publishers.js +++ b/bigbluebutton-html5/imports/api/users/server/publishers.js @@ -40,8 +40,9 @@ function publishCurrentUser(...args) { Meteor.publish('current-user', publishCurrentUser); -function users() { - const tokenValidation = AuthTokenValidation.findOne({ connectionId: this.connection.id }); +async function users() { + const tokenValidation = await AuthTokenValidation + .findOneAsync({ connectionId: this.connection.id }); if (!tokenValidation || tokenValidation.validationStatus !== ValidationStates.VALIDATED) { Logger.warn(`Publishing Users was requested by unauth connection ${this.connection.id}`); @@ -63,15 +64,16 @@ function users() { left: false, }; - const User = Users.findOne({ userId, meetingId }, { fields: { role: 1 } }); + const User = await Users.findOneAsync({ userId, meetingId }, { fields: { role: 1 } }); if (!!User && User.role === ROLE_MODERATOR) { selector.$or.push({ 'breakoutProps.isBreakoutUser': true, 'breakoutProps.parentId': meetingId, }); // Monitor this publication and stop it when user is not a moderator anymore - const comparisonFunc = () => { - const user = Users.findOne({ userId, meetingId }, { fields: { role: 1, userId: 1 } }); + const comparisonFunc = async () => { + const user = await Users.findOneAsync({ userId, meetingId }, + { fields: { role: 1, userId: 1 } }); const condition = user.role === ROLE_MODERATOR; if (!condition) { Logger.info(`conditions aren't filled anymore in publication ${this._name}: diff --git a/bigbluebutton-html5/imports/ui/services/auth/index.js b/bigbluebutton-html5/imports/ui/services/auth/index.js index 43169e4646..6a5521dbac 100755 --- a/bigbluebutton-html5/imports/ui/services/auth/index.js +++ b/bigbluebutton-html5/imports/ui/services/auth/index.js @@ -239,27 +239,27 @@ class Auth { description: 'Authentication timeout', }); }, CONNECTION_TIMEOUT); + Meteor.callAsync('validateAuthToken', this.meetingID, this.userID, this.token, this.externUserID) + .then((result) => { + const authenticationTokenValidation = result; + if (!authenticationTokenValidation) return; - Meteor.call('validateAuthToken', this.meetingID, this.userID, this.token, this.externUserID, (err, result) => { - const authenticationTokenValidation = result; - if (!authenticationTokenValidation) return; - - switch (authenticationTokenValidation.validationStatus) { - case ValidationStates.INVALID: - reject({ error: 403, description: authenticationTokenValidation.reason }); - break; - case ValidationStates.VALIDATED: - initCursorStreamListener(); - initAnnotationsStreamListener(); - clearTimeout(validationTimeout); - this.connectionID = authenticationTokenValidation.connectionId; - this.connectionAuthTime = new Date().getTime(); - Session.set('userWillAuth', false); - setTimeout(() => resolve(true), 100); - break; - default: - } - }); + switch (authenticationTokenValidation.validationStatus) { + case ValidationStates.INVALID: + reject({ error: 403, description: authenticationTokenValidation.reason }); + break; + case ValidationStates.VALIDATED: + initCursorStreamListener(); + initAnnotationsStreamListener(); + clearTimeout(validationTimeout); + this.connectionID = authenticationTokenValidation.connectionId; + this.connectionAuthTime = new Date().getTime(); + Session.set('userWillAuth', false); + setTimeout(() => resolve(true), 100); + break; + default: + } + }); }); }