diff --git a/back/models/image-collection.js b/back/models/image-collection.js index 2c4d274ee..69905beca 100644 --- a/back/models/image-collection.js +++ b/back/models/image-collection.js @@ -9,10 +9,11 @@ module.exports = Self => { * @return {boolean} True for user with read privileges */ Self.hasReadRole = async(ctx, name, options) => { - const collection = await Self.findOne({where: {name}}, { + const collection = await Self.findOne({ include: { relation: 'readRole' - } + }, + where: {name} }, options); return await hasRole(ctx, collection, options); diff --git a/back/models/specs/dms.spec.js b/back/models/specs/dms.spec.js index e539387fb..3f13e88ff 100644 --- a/back/models/specs/dms.spec.js +++ b/back/models/specs/dms.spec.js @@ -37,14 +37,14 @@ describe('Dms', () => { const dmsId = 1; it('should return a true for an employee with permission', async() => { let ctx = {req: {accessToken: {userId: 1107}}}; - const result = await Dms.checkRole(ctx, dmsId, 'READ'); + const result = await Dms.checkRole(ctx, dmsId); expect(result).toBeTruthy(); }); it('should return false for an employee without permission', async() => { let ctx = {req: {accessToken: {userId: 1101}}}; - const result = await Dms.checkRole(ctx, dmsId, 'READ'); + const result = await Dms.checkRole(ctx, dmsId); expect(result).toBeFalsy(); }); diff --git a/db/changes/231601/00-User.sql b/db/changes/231601/00-User.sql deleted file mode 100644 index 8a7054403..000000000 --- a/db/changes/231601/00-User.sql +++ /dev/null @@ -1,21 +0,0 @@ -create or replace definer = root@localhost view `salix`.`User` as -select `account`.`user`.`id` AS `id`, - `account`.`user`.`realm` AS `realm`, - `account`.`user`.`name` AS `name`, - `account`.`user`.`nickname` AS `nickname`, - `account`.`user`.`bcryptPassword` AS `password`, - `account`.`user`.`role` AS `role`, - `account`.`user`.`active` AS `active`, - `account`.`user`.`email` AS `email`, - `account`.`user`.`emailVerified` AS `emailVerified`, - `account`.`user`.`verificationToken` AS `verificationToken`, - `account`.`user`.`lang` AS `lang`, - `account`.`user`.`lastPassChange` AS `lastPassChange`, - `account`.`user`.`created` AS `created`, - `account`.`user`.`updated` AS `updated`, - `account`.`user`.`image` AS `image`, - `account`.`user`.`recoverPass` AS `recoverPass`, - `account`.`user`.`sync` AS `sync`, - `account`.`user`.`hasGrant` AS `hasGrant` -from `account`.`user`; -