WiP on permissions
Table of shares per user
This commit is contained in:
parent
89c9615592
commit
89256d62bd
20 changed files with 354 additions and 171 deletions
|
@ -15,24 +15,8 @@ function getAnonymousConfig(context) {
|
|||
}
|
||||
|
||||
function getAuthenticatedConfig(context) {
|
||||
const roles = {};
|
||||
for (const entityTypeId in config.roles) {
|
||||
const rolesPerEntityType = {};
|
||||
for (const roleId in config.roles[entityTypeId]) {
|
||||
const roleSpec = config.roles[entityTypeId][roleId];
|
||||
|
||||
rolesPerEntityType[roleId] = {
|
||||
name: roleSpec.name,
|
||||
description: roleSpec.description
|
||||
}
|
||||
}
|
||||
roles[entityTypeId] = rolesPerEntityType;
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
userId: context.user.id,
|
||||
roles
|
||||
userId: context.user.id
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ async function ajaxList(params, queryFun, columns, mapFun) {
|
|||
});
|
||||
}
|
||||
|
||||
async function ajaxListWithPermissions(context, fetchSpecs, params, queryFun, columns) {
|
||||
async function ajaxListWithPermissions(context, fetchSpecs, params, queryFun, columns, map) {
|
||||
const permCols = [];
|
||||
for (const fetchSpec of fetchSpecs) {
|
||||
const entityType = permissions.getEntityType(fetchSpec.entityTypeId);
|
||||
|
@ -121,11 +121,13 @@ async function ajaxListWithPermissions(context, fetchSpecs, params, queryFun, co
|
|||
for (const fetchSpec of fetchSpecs) {
|
||||
const entityType = permissions.getEntityType(fetchSpec.entityTypeId);
|
||||
|
||||
query = query.innerJoin(
|
||||
function () {
|
||||
return this.from(entityType.permissionsTable).select('entity').where('user', context.user.id).whereIn('operation', fetchSpec.requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`);
|
||||
},
|
||||
`permitted__${fetchSpec.entityTypeId}.entity`, `${entityType.entitiesTable}.id`)
|
||||
if (fetchSpec.requiredOperations) {
|
||||
query = query.innerJoin(
|
||||
function () {
|
||||
return this.from(entityType.permissionsTable).select('entity').where('user', context.user.id).whereIn('operation', fetchSpec.requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`);
|
||||
},
|
||||
`permitted__${fetchSpec.entityTypeId}.entity`, `${entityType.entitiesTable}.id`)
|
||||
}
|
||||
}
|
||||
|
||||
return query;
|
||||
|
|
|
@ -110,7 +110,7 @@ if (config.ldap.enabled && LdapStrategy) {
|
|||
|
||||
} catch (err) {
|
||||
if (err instanceof interoperableErrors.NotFoundError) {
|
||||
const userId = await users.create({
|
||||
const userId = await users.create(null, {
|
||||
username: profile[config.ldap.uidTag],
|
||||
role: config.ldap.newUserRole,
|
||||
namespace: config.ldap.newUserNamespaceId
|
||||
|
@ -143,6 +143,6 @@ if (config.ldap.enabled && LdapStrategy) {
|
|||
})));
|
||||
|
||||
passport.serializeUser((user, done) => done(null, user.id));
|
||||
passport.deserializeUser((id, done) => nodeifyPromise(users.getByIdNoPerms(id), done));
|
||||
passport.deserializeUser((id, done) => nodeifyPromise(users.getById(null, id), done));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue