5488-use_checkAccessAcl #1482

Merged
alexm merged 32 commits from 5488-use_checkAccessAcl into dev 2023-05-29 05:20:29 +00:00
3 changed files with 5 additions and 25 deletions
Showing only changes of commit c3038a4d61 - Show all commits

View File

@ -9,10 +9,11 @@ module.exports = Self => {
* @return {boolean} True for user with read privileges * @return {boolean} True for user with read privileges
*/ */
Self.hasReadRole = async(ctx, name, options) => { Self.hasReadRole = async(ctx, name, options) => {
const collection = await Self.findOne({where: {name}}, { const collection = await Self.findOne({
Review

Aço dua 3 anys mal, el objecte estava mal ficat i mai es fea la relacio

Aço dua 3 anys mal, el objecte estava mal ficat i mai es fea la relacio
include: { include: {
relation: 'readRole' relation: 'readRole'
} },
where: {name}
}, options); }, options);
return await hasRole(ctx, collection, options); return await hasRole(ctx, collection, options);

View File

@ -37,14 +37,14 @@ describe('Dms', () => {
const dmsId = 1; const dmsId = 1;
it('should return a true for an employee with permission', async() => { it('should return a true for an employee with permission', async() => {
let ctx = {req: {accessToken: {userId: 1107}}}; let ctx = {req: {accessToken: {userId: 1107}}};
const result = await Dms.checkRole(ctx, dmsId, 'READ'); const result = await Dms.checkRole(ctx, dmsId);
expect(result).toBeTruthy(); expect(result).toBeTruthy();
}); });
it('should return false for an employee without permission', async() => { it('should return false for an employee without permission', async() => {
let ctx = {req: {accessToken: {userId: 1101}}}; let ctx = {req: {accessToken: {userId: 1101}}};
const result = await Dms.checkRole(ctx, dmsId, 'READ'); const result = await Dms.checkRole(ctx, dmsId);
expect(result).toBeFalsy(); expect(result).toBeFalsy();
}); });

View File

@ -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`;