28 lines
No EOL
750 B
JavaScript
28 lines
No EOL
750 B
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { check } from 'meteor/check';
|
|
|
|
export const UserInfo = new Mongo.Collection('userInfo');
|
|
|
|
UserInfo.allow({
|
|
insert: function(userId, doc){
|
|
// if user id exists, allow insert
|
|
return !!userId;
|
|
},
|
|
});
|
|
|
|
Meteor.methods({
|
|
async 'addUserToTenant' (userId, tenant_id) {
|
|
check(userId, String);
|
|
check(tenant_id, String);
|
|
|
|
if (!this.userId) {
|
|
throw new Meteor.Error('You are not allowed to add tenants for users. Make sure you are logged in with valid user credentials.');
|
|
}
|
|
|
|
return await UserInfo.insertAsync({
|
|
userId: userId,
|
|
tenant_id: tenant_id,
|
|
});
|
|
},
|
|
}); |