2017-02-24 02:52:44 +08:00
|
|
|
import { Meteor } from 'meteor/meteor';
|
|
|
|
import { check } from 'meteor/check';
|
|
|
|
import Logger from '/imports/startup/server/logger';
|
2017-10-12 09:02:23 +08:00
|
|
|
import Users from '/imports/api/2.0/users';
|
2016-05-13 01:43:59 +08:00
|
|
|
|
2017-10-12 09:02:23 +08:00
|
|
|
export default function createDummyUser2x(meetingId, userId, authToken) {
|
2017-02-24 02:52:44 +08:00
|
|
|
check(meetingId, String);
|
|
|
|
check(userId, String);
|
|
|
|
check(authToken, String);
|
|
|
|
|
|
|
|
const User = Users.findOne({ meetingId, userId });
|
|
|
|
if (User) {
|
2017-06-03 03:25:02 +08:00
|
|
|
throw new Meteor.Error('existing-user', 'Tried to create a dummy user for an existing user');
|
2016-05-16 22:35:59 +08:00
|
|
|
}
|
2017-02-24 02:52:44 +08:00
|
|
|
|
|
|
|
const doc = {
|
|
|
|
meetingId,
|
|
|
|
userId,
|
|
|
|
authToken,
|
|
|
|
clientType: 'HTML5',
|
2017-03-11 03:18:23 +08:00
|
|
|
validated: null,
|
2017-02-24 02:52:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const cb = (err, numChanged) => {
|
|
|
|
if (err) {
|
|
|
|
return Logger.error(`Creating dummy user to collection: ${err}`);
|
|
|
|
}
|
|
|
|
|
2017-10-12 09:02:23 +08:00
|
|
|
Logger.info(`Created dummy user 2x id=${userId} token=${authToken} meeting=${meetingId}`);
|
2017-02-24 02:52:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
return Users.insert(doc, cb);
|
2017-06-03 03:25:02 +08:00
|
|
|
}
|