refs #5770 feat usersMap
This commit is contained in:
parent
faf747ee5d
commit
48a533e4a9
|
@ -1,5 +1,6 @@
|
|||
// const execFile = require('child_process').execFile;
|
||||
const app = require('vn-loopback/server/server');
|
||||
const SAMBA_TOOL = 'samba-tool';
|
||||
// const RoleControlFlags = {
|
||||
// ACCOUNTDISABLE: 0x2
|
||||
// };
|
||||
|
@ -42,25 +43,16 @@ async function sambaTool(command, args = []) {
|
|||
return ['employee', 'customer', 'agency', 'group1'];
|
||||
else if (args[0] === 'add') {
|
||||
return new Promise(resolve => {
|
||||
resolve(`samba-tool add ${args[1]}`);
|
||||
resolve(`${SAMBA_TOOL} add ${args[1]}`);
|
||||
});
|
||||
} else if (args[0] === 'delete') {
|
||||
} else if (['delete', 'listmembers'].includes(args[0])) {
|
||||
return new Promise(resolve => {
|
||||
resolve(`samba-tool ${args[0]} ${args[1]}`);
|
||||
resolve(`${SAMBA_TOOL} ${args[0]} ${args[1]}`);
|
||||
});
|
||||
} else if (args[0] === 'listmembers') {
|
||||
} else if (['addmembers', 'removemembers'].includes(args[0])) {
|
||||
return new Promise(resolve => {
|
||||
resolve(`samba-tool ${args[0]} ${args[1]}`);
|
||||
resolve(`${SAMBA_TOOL} ${args[0]} ${args[1]} ${args[2]}`);
|
||||
});
|
||||
} else if (args[0] === 'addmembers') {
|
||||
return new Promise(resolve => {
|
||||
resolve(`samba-tool ${args[0]} ${args[1]} ${args[2]}`);
|
||||
});
|
||||
} else if (args[0] === 'removemembers') {
|
||||
return new Promise(resolve => {
|
||||
resolve(`samba-tool ${args[0]} ${args[1]} ${args[2]}`);
|
||||
});
|
||||
// return `samba-tool ${args[0]} ${args[1]} ${args[2]}`;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -95,6 +87,17 @@ async function syncRoles() {
|
|||
expect(rolesToInsert.length).toEqual(2);
|
||||
// OBTENER USUARIOS Y SUS ROLES
|
||||
if (rolesToDelete.length > 0 || rolesToInsert.length > 0) {
|
||||
let users = await $.VnUser.find({
|
||||
|
||||
include: {
|
||||
relation: 'role',
|
||||
scope: {fields: ['name'],
|
||||
where: {'name': {inq: rolesToInsert}}
|
||||
}
|
||||
},
|
||||
fields: ['name', 'roleFk'],
|
||||
where: {'active': true}
|
||||
});
|
||||
let accounts = await $.Account.find({
|
||||
fields: ['id'],
|
||||
include: {
|
||||
|
@ -111,6 +114,12 @@ async function syncRoles() {
|
|||
}
|
||||
}
|
||||
});
|
||||
let userMap = toMap(users, user => {
|
||||
let role = user.role();
|
||||
if (!role) return;
|
||||
return {key: role.name, val: user.name};
|
||||
});
|
||||
console.log(userMap);
|
||||
let accountMap = toMap(accounts, e => {
|
||||
let user = e.user();
|
||||
if (!user) return;
|
||||
|
|
Loading…
Reference in New Issue