mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-26 15:58:50 +00:00
42 lines
No EOL
1.5 KiB
JavaScript
42 lines
No EOL
1.5 KiB
JavaScript
import { Meteor } from 'meteor/meteor';
|
|
import { Mongo } from 'meteor/mongo';
|
|
import { check } from 'meteor/check';
|
|
|
|
Meteor.methods({
|
|
'addToRole' (role) {
|
|
let countOfUsers = Meteor.users.find().count();
|
|
|
|
// if users = 1 - set to role passed in function call
|
|
if (countOfUsers > 1) {
|
|
console.log("User id for role: " + Meteor.userId() );
|
|
let userId = Meteor.userId();
|
|
Roles.addUsersToRoles(userId, role);
|
|
Meteor.call('add.darkPref', false, function(err, result) {
|
|
if (err) {
|
|
console.log(" ERROR: can't set user dark mode preference: " + err);
|
|
} else {
|
|
console.log(" SUCCESSFULLY set user dark mode preference.");
|
|
}
|
|
});
|
|
} else if (countOfUsers == 1) {
|
|
console.log("Creating first system admin user: " + Meteor.userId() );
|
|
let userId = Meteor.userId();
|
|
Roles.addUsersToRoles(userId, "systemadmin");
|
|
Meteor.call('add.darkPref', false, function(err, result) {
|
|
if (err) {
|
|
console.log(" ERROR: can't set user dark mode preference: " + err);
|
|
} else {
|
|
console.log(" SUCCESSFULLY set user dark mode preference.");
|
|
}
|
|
});
|
|
}
|
|
},
|
|
'edit.userPass' (userId, newPassword) {
|
|
|
|
},
|
|
'delete.userFromSys' (userId) {
|
|
check(userId, String);
|
|
|
|
return Meteor.users.remove({ _id: userId });
|
|
},
|
|
}); |