2016-05-05 02:29:43 +08:00
|
|
|
import { logger } from '/imports/startup/server/logger';
|
2016-05-13 03:22:51 +08:00
|
|
|
import { createDummyUser } from '/imports/api/users/server/modifiers/createDummyUser';
|
2016-06-02 01:18:13 +08:00
|
|
|
import { publish } from '/imports/api/common/server/helpers';
|
2016-05-02 22:48:20 +08:00
|
|
|
|
|
|
|
Meteor.methods({
|
2016-05-05 05:49:01 +08:00
|
|
|
// Construct and send a message to bbb-web to validate the user
|
2016-05-17 02:12:27 +08:00
|
|
|
validateAuthToken(credentials) {
|
2016-08-17 23:48:03 +08:00
|
|
|
const REDIS_CONFIG = Meteor.settings.redis;
|
2016-05-17 02:12:27 +08:00
|
|
|
const { meetingId, requesterUserId, requesterToken } = credentials;
|
2016-05-05 05:49:01 +08:00
|
|
|
logger.info('sending a validate_auth_token with', {
|
2016-05-17 02:12:27 +08:00
|
|
|
userid: requesterUserId,
|
|
|
|
authToken: requesterToken,
|
2016-05-05 05:49:01 +08:00
|
|
|
meetingid: meetingId,
|
|
|
|
});
|
2016-05-16 22:35:59 +08:00
|
|
|
let message = {
|
2016-05-05 05:49:01 +08:00
|
|
|
payload: {
|
2016-05-17 02:12:27 +08:00
|
|
|
auth_token: requesterToken,
|
|
|
|
userid: requesterUserId,
|
2016-05-05 05:49:01 +08:00
|
|
|
meeting_id: meetingId,
|
|
|
|
},
|
|
|
|
header: {
|
|
|
|
timestamp: new Date().getTime(),
|
2016-05-17 02:12:27 +08:00
|
|
|
reply_to: `${meetingId}/${requesterUserId}`,
|
2016-05-05 05:49:01 +08:00
|
|
|
name: 'validate_auth_token',
|
|
|
|
},
|
|
|
|
};
|
2016-05-17 02:12:27 +08:00
|
|
|
if ((requesterToken != null) && (requesterUserId != null) && (meetingId != null)) {
|
|
|
|
createDummyUser(meetingId, requesterUserId, requesterToken);
|
2016-08-17 23:48:03 +08:00
|
|
|
return publish(REDIS_CONFIG.channels.toBBBApps.meeting, message);
|
2016-05-05 05:49:01 +08:00
|
|
|
} else {
|
|
|
|
return logger.info('did not have enough information to send a validate_auth_token message');
|
|
|
|
}
|
|
|
|
},
|
2016-05-02 22:48:20 +08:00
|
|
|
});
|