fix some problems with using same user in multiple tabs
This commit is contained in:
parent
ac0a014571
commit
087939855e
@ -11,8 +11,10 @@ export default function upsertValidationState(meetingId, userId, validationStatu
|
||||
userId,
|
||||
connectionId,
|
||||
validationStatus,
|
||||
updatedAt: new Date().getTime(),
|
||||
},
|
||||
};
|
||||
|
||||
const cb = (err, numChanged) => {
|
||||
if (err) {
|
||||
Logger.error(`Could not upsert to collection AuthTokenValidation: ${err}`);
|
||||
|
@ -1,18 +1,14 @@
|
||||
import { Meteor } from 'meteor/meteor';
|
||||
import AuthTokenValidation from '/imports/api/auth-token-validation';
|
||||
import Logger from '/imports/startup/server/logger';
|
||||
import { extractCredentials } from '/imports/api/common/server/helpers';
|
||||
|
||||
function authTokenValidation() {
|
||||
const connectionId = this.connection.id;
|
||||
const { meetingId, requesterUserId } = extractCredentials(this.userId);
|
||||
function authTokenValidation({ meetingId, userId }) {
|
||||
const selector = {
|
||||
meetingId,
|
||||
userId: requesterUserId,
|
||||
connectionId,
|
||||
userId,
|
||||
};
|
||||
|
||||
Logger.debug(`Publishing auth-token-validation for ${meetingId} ${requesterUserId}`);
|
||||
Logger.debug(`Publishing auth-token-validation for ${meetingId} ${userId}`);
|
||||
|
||||
return AuthTokenValidation.find(selector);
|
||||
}
|
||||
|
@ -26,11 +26,10 @@ export default function userLeaving(meetingId, userId, connectionId) {
|
||||
const auth = AuthTokenValidation.findOne({
|
||||
meetingId,
|
||||
userId,
|
||||
connectionId,
|
||||
});
|
||||
}, { sort: { updatedAt: -1 } });
|
||||
|
||||
// If the current user connection is not the same that triggered the leave we skip
|
||||
if (User.connectionId !== connectionId && !auth) {
|
||||
if (auth?.connectionId !== connectionId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,7 @@ import { withTracker } from 'meteor/react-meteor-data';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
import PropTypes from 'prop-types';
|
||||
import Auth from '/imports/ui/services/auth';
|
||||
import AuthTokenValidation from '/imports/api/auth-token-validation';
|
||||
import Users from '/imports/api/users';
|
||||
import Meetings from '/imports/api/meetings';
|
||||
import { notify } from '/imports/ui/services/notification';
|
||||
@ -77,6 +78,18 @@ const currentUserEmoji = currentUser => (currentUser ? {
|
||||
});
|
||||
|
||||
export default injectIntl(withModalMounter(withTracker(({ intl, baseControls }) => {
|
||||
const authTokenValidation = AuthTokenValidation.findOne({}, { sort: { updatedAt: -1 } });
|
||||
|
||||
if (authTokenValidation.connectionId !== Meteor.connection._lastSessionId) {
|
||||
endMeeting('403');
|
||||
}
|
||||
|
||||
Users.find({ userId: Auth.userID }).observe({
|
||||
removed() {
|
||||
endMeeting('403');
|
||||
},
|
||||
});
|
||||
|
||||
const currentUser = Users.findOne({ userId: Auth.userID }, { fields: { approved: 1, emoji: 1 } });
|
||||
const currentMeeting = Meetings.findOne({ meetingId: Auth.meetingID },
|
||||
{ fields: { publishedPoll: 1, voiceProp: 1 } });
|
||||
@ -86,17 +99,6 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
|
||||
baseControls.updateLoadingState(intl.formatMessage(intlMessages.waitingApprovalMessage));
|
||||
}
|
||||
|
||||
// Check if user is removed out of the session
|
||||
Users.find({ userId: Auth.userID }, { fields: { connectionId: 1, ejected: 1 } }).observeChanges({
|
||||
changed(id, fields) {
|
||||
const hasNewConnection = 'connectionId' in fields && (fields.connectionId !== Meteor.connection._lastSessionId);
|
||||
|
||||
if (fields.ejected || hasNewConnection) {
|
||||
endMeeting('403');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const UserInfo = UserInfos.find({
|
||||
meetingId: Auth.meetingID,
|
||||
requesterUserId: Auth.userID,
|
||||
|
Loading…
Reference in New Issue
Block a user