Fixing some small registration and login isues
This commit is contained in:
parent
5aa2feff7b
commit
9ed5089508
8 changed files with 66 additions and 44 deletions
|
|
@ -4,28 +4,25 @@ import { check } from 'meteor/check';
|
|||
import { Roles } from 'meteor/roles';
|
||||
|
||||
Meteor.methods({
|
||||
'addToRole' (role) {
|
||||
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.addUsersToRolesAysnc(userId, role);
|
||||
} else if (countOfUsers == 1) {
|
||||
Roles.addUsersToRolesAsync(userId, "systemadmin");
|
||||
} else {
|
||||
console.log("The count of users didn't seem to work when adding a new user.");
|
||||
}
|
||||
async 'addToRole' (role) {
|
||||
try {
|
||||
const user = await Meteor.userAsync();
|
||||
let countOfUsers = await Meteor.users.find().countAsync();
|
||||
if (user) {
|
||||
let userId = user._id;
|
||||
if (countOfUsers > 1) {
|
||||
await Roles.addUsersToRolesAsync(userId, role);
|
||||
} else if (countOfUsers == 1) {
|
||||
await Roles.addUsersToRolesAsync(userId, "systemadmin");
|
||||
} else {
|
||||
console.log(" ---- No user info found.")
|
||||
console.log("The count of users didn't seem to work when adding a new user.");
|
||||
}
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting user info on server: " + error);
|
||||
} else {
|
||||
console.log(" ---- No user info found.")
|
||||
}
|
||||
}
|
||||
getUserInfo();
|
||||
} catch(error) {
|
||||
console.log(" ERROR getting user info on server: " + error);
|
||||
}
|
||||
},
|
||||
'edit.userPass' (userId, newPassword) {
|
||||
check(userId, String);
|
||||
|
|
@ -44,28 +41,26 @@ Meteor.methods({
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
'delete.userFromSys' (userId) {
|
||||
async 'delete.userFromSys' (userId) {
|
||||
check(userId, String);
|
||||
|
||||
return Meteor.users.remove({ _id: userId });
|
||||
return await Meteor.users.removeAsync({ _id: userId });
|
||||
},
|
||||
'update.userEmail' (userId, email) {
|
||||
async 'update.userEmail' (userId, email) {
|
||||
check(userId, String);
|
||||
check(email, String);
|
||||
|
||||
return Meteor.users.update({ _id: userId }, {
|
||||
return await Meteor.users.updateAsync({ _id: userId }, {
|
||||
$set: {
|
||||
'emails.0.address': email,
|
||||
}
|
||||
});
|
||||
},
|
||||
'edit.userRole' (userId, role) {
|
||||
async 'edit.userRole' (userId, role) {
|
||||
check(userId, String);
|
||||
check(role, String);
|
||||
|
||||
return Roles.setUserRoles(userId, role);
|
||||
return await Roles.setUserRolesAsync(userId, role);
|
||||
},
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue