bigbluebutton-Github/bigbluebutton-html5/imports/api/users/server/methods/validateAuthToken.js

34 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-02-07 23:29:27 +08:00
import { Meteor } from 'meteor/meteor';
import RedisPubSub from '/imports/startup/server/redis';
2017-02-07 23:29:27 +08:00
import Logger from '/imports/startup/server/logger';
import upsertValidationState from '/imports/api/auth-token-validation/server/modifiers/upsertValidationState';
import { ValidationStates } from '/imports/api/auth-token-validation';
import pendingAuthenticationsStore from '../store/pendingAuthentications';
2017-02-07 23:29:27 +08:00
export default function validateAuthToken(meetingId, requesterUserId, requesterToken, externalId) {
2021-05-06 00:47:43 +08:00
try {
const REDIS_CONFIG = Meteor.settings.private.redis;
const CHANNEL = REDIS_CONFIG.channels.toAkkaApps;
const EVENT_NAME = 'ValidateAuthTokenReqMsg';
2017-02-07 23:29:27 +08:00
2021-05-06 00:47:43 +08:00
Logger.debug('ValidateAuthToken method called', { meetingId, requesterUserId, requesterToken, externalId });
2021-01-30 01:27:13 +08:00
2021-05-06 00:47:43 +08:00
if (!meetingId) return false;
2021-05-06 00:47:43 +08:00
// Store reference of methodInvocationObject ( to postpone the connection userId definition )
pendingAuthenticationsStore.add(meetingId, requesterUserId, requesterToken, this);
upsertValidationState(meetingId, requesterUserId, ValidationStates.VALIDATING, this.connection.id);
2021-05-06 00:47:43 +08:00
const payload = {
userId: requesterUserId,
authToken: requesterToken,
};
2017-02-07 23:29:27 +08:00
2021-05-06 00:47:43 +08:00
Logger.info(`User '${requesterUserId}' is trying to validate auth token for meeting '${meetingId}' from connection '${this.connection.id}'`);
2017-02-07 23:29:27 +08:00
2021-05-06 00:47:43 +08:00
return RedisPubSub.publishUserMessage(CHANNEL, EVENT_NAME, meetingId, requesterUserId, payload);
} catch (err) {
Logger.error(`Exception while invoking method validateAuthToken ${err.stack}`);
}
2017-06-03 03:25:02 +08:00
}