mirror of
https://gitlab.com/bmcgonag/get_my.git
synced 2026-03-27 00:08:49 +00:00
Updating framework to meteor 3 and later
This commit is contained in:
parent
717994508a
commit
cca29bc591
58 changed files with 2332 additions and 1611 deletions
|
|
@ -3,52 +3,60 @@ import { Mongo } from 'meteor/mongo';
|
|||
import { check } from 'meteor/check';
|
||||
import { TaskItems } from '../imports/api/tasks';
|
||||
import { SysConfig } from '../imports/api/systemConfig';
|
||||
import { Roles } from 'meteor/roles';
|
||||
|
||||
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.darkModePref', "light", function(err, result) {
|
||||
if (err) {
|
||||
console.log(" ERROR: can't set user dark mode preference: " + err);
|
||||
const getUserInfo = async() => {
|
||||
try {
|
||||
let countOfUsers = await Meteor.users.find().countAsync();
|
||||
const user = await Meteor.userAsync();
|
||||
if (user) {
|
||||
let userId = user._id;
|
||||
if (countOfUsers > 1) {
|
||||
Roles.addUsersToRolesAsync(userId, role);
|
||||
const result = await Meteor.callAsync('add.darkModePref', "light");
|
||||
if (!result) {
|
||||
console.log(" ERROR: can't set user dark mode preference: " + err);
|
||||
} else {
|
||||
// console.log(" SUCCESSFULLY set user dark mode preference.");
|
||||
}
|
||||
} else if (countOfUsers == 1) {
|
||||
Roles.addUsersToRolesAsync(userId, "systemadmin");
|
||||
const result = await Meteor.callAsync('add.darkModePref', "light");
|
||||
if (!result) {
|
||||
console.log(" ERROR: can't set user dark mode preference: " + err);
|
||||
} else {
|
||||
console.log(" SUCCESSFULLY set user dark mode preference.");
|
||||
}
|
||||
} else {
|
||||
console.log("The count of users didn't seem to work when adding a new user.");
|
||||
}
|
||||
} else {
|
||||
// console.log(" SUCCESSFULLY set user dark mode preference.");
|
||||
console.log(" ---- No user info found.")
|
||||
}
|
||||
});
|
||||
} else if (countOfUsers == 1) {
|
||||
console.log("Creating first system admin user: " + Meteor.userId() );
|
||||
let userId = Meteor.userId();
|
||||
Roles.addUsersToRoles(userId, "systemadmin");
|
||||
Meteor.call('add.darkModePref', "light", 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.");
|
||||
}
|
||||
});
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting user info on server: " + error);
|
||||
}
|
||||
}
|
||||
getUserInfo();
|
||||
},
|
||||
'edit.userPass' (userId, newPassword) {
|
||||
check(userId, String);
|
||||
check(newPassword, String);
|
||||
|
||||
return Accounts.setPassword(userId, newPassword);
|
||||
return Accounts.setPasswordAsync(userId, newPassword);
|
||||
},
|
||||
'delete.userFromSys' (userId) {
|
||||
check(userId, String);
|
||||
|
||||
return Meteor.users.remove({ _id: userId });
|
||||
return Meteor.users.removeAsync({ _id: userId });
|
||||
},
|
||||
'update.userEmail' (userId, email) {
|
||||
check(userId, String);
|
||||
check(email, String);
|
||||
|
||||
return Meteor.users.update({ _id: userId }, {
|
||||
return Meteor.users.updateAsync({ _id: userId }, {
|
||||
$set: {
|
||||
'emails.0.address': email,
|
||||
}
|
||||
|
|
@ -58,6 +66,6 @@ Meteor.methods({
|
|||
check(userId, String);
|
||||
check(role, String);
|
||||
|
||||
return Roles.setUserRoles(userId, role);
|
||||
return Roles.setUserRolesAsync(userId, role);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue