Harmonization with IVIS
This commit is contained in:
parent
428fb9db7b
commit
397f85dac4
41 changed files with 8587 additions and 10940 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
const knex = require('./knex');
|
||||
const entitySettings = require('./entity-settings');
|
||||
const { enforce } = require('./helpers');
|
||||
const shares = require('../models/shares');
|
||||
|
||||
async function ajaxListTx(tx, params, queryFun, columns, options) {
|
||||
options = options || {};
|
||||
|
@ -109,7 +111,8 @@ async function ajaxListTx(tx, params, queryFun, columns, options) {
|
|||
}
|
||||
|
||||
async function ajaxListWithPermissionsTx(tx, context, fetchSpecs, params, queryFun, columns, options) {
|
||||
// Note that this function is not intended to be used with the synthetic admin context obtained by contextHelpers.getAdminContext()
|
||||
enforce(!context.user.admin, 'ajaxListWithPermissionsTx is not supposed to be called by assumed admin');
|
||||
|
||||
options = options || {};
|
||||
|
||||
const permCols = [];
|
||||
|
@ -138,13 +141,18 @@ async function ajaxListWithPermissionsTx(tx, context, fetchSpecs, params, queryF
|
|||
const entityType = entitySettings.getEntityType(fetchSpec.entityTypeId);
|
||||
|
||||
if (fetchSpec.requiredOperations) {
|
||||
const requiredOperations = shares.filterPermissionsByRestrictedAccessHandler(context, fetchSpec.entityTypeId, null, fetchSpec.requiredOperations, 'ajaxListWithPermissionsTx');
|
||||
const entityIdColumn = fetchSpec.column ? fetchSpec.column : entityType.entitiesTable + '.id';
|
||||
|
||||
query = query.innerJoin(
|
||||
function () {
|
||||
return this.from(entityType.permissionsTable).distinct('entity').where('user', context.user.id).whereIn('operation', fetchSpec.requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`);
|
||||
},
|
||||
`permitted__${fetchSpec.entityTypeId}.entity`, entityIdColumn)
|
||||
if (requiredOperations.length > 0) {
|
||||
query = query.innerJoin(
|
||||
function () {
|
||||
return this.from(entityType.permissionsTable).distinct('entity').where('user', context.user.id).whereIn('operation', requiredOperations).as(`permitted__${fetchSpec.entityTypeId}`);
|
||||
},
|
||||
`permitted__${fetchSpec.entityTypeId}.entity`, entityIdColumn)
|
||||
} else {
|
||||
query = query.whereRaw('FALSE');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -186,9 +194,7 @@ async function ajaxListWithPermissions(context, fetchSpecs, params, queryFun, co
|
|||
});
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
ajaxListTx,
|
||||
ajaxList,
|
||||
ajaxListWithPermissionsTx,
|
||||
ajaxListWithPermissions
|
||||
};
|
||||
module.exports.ajaxListTx = ajaxListTx;
|
||||
module.exports.ajaxList = ajaxList;
|
||||
module.exports.ajaxListWithPermissionsTx = ajaxListWithPermissionsTx;
|
||||
module.exports.ajaxListWithPermissions = ajaxListWithPermissions;
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const moment = require('moment');
|
||||
const path = require('path');
|
||||
|
||||
const knexConstructor = require('knex');
|
||||
|
||||
const knex = require('knex')({
|
||||
client: 'mysql',
|
||||
|
@ -16,9 +18,9 @@ const knex = require('knex')({
|
|||
]
|
||||
},
|
||||
migrations: {
|
||||
directory: __dirname + '/../setup/knex/migrations'
|
||||
directory: path.join(__dirname, '..', 'setup', 'knex', 'migrations')
|
||||
}
|
||||
//, debug: true
|
||||
//, debug: true
|
||||
});
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
'use strict';
|
||||
|
||||
const { enforce } = require('./helpers');
|
||||
const shares = require('../models/shares');
|
||||
const interoperableErrors = require('../../shared/interoperable-errors');
|
||||
const shares = require('../models/shares');
|
||||
|
||||
async function validateEntity(tx, entity) {
|
||||
enforce(entity.namespace, 'Entity namespace not set');
|
||||
|
|
|
@ -222,7 +222,7 @@ if (LdapStrategy) {
|
|||
module.exports.isAuthMethodLocal = true;
|
||||
|
||||
passport.use(new LocalStrategy(nodeifyFunction(async (username, password) => {
|
||||
return await users.getByUsernameIfPasswordMatch(username, password);
|
||||
return await users.getByUsernameIfPasswordMatch(contextHelpers.getAdminContext(), username, password);
|
||||
})));
|
||||
|
||||
passport.serializeUser((user, done) => done(null, user.id));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue