@solidstarters/solid-core 1.2.34 → 1.2.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/services/crud-helper.service.d.ts +1 -0
- package/dist/services/crud-helper.service.d.ts.map +1 -1
- package/dist/services/crud-helper.service.js +5 -0
- package/dist/services/crud-helper.service.js.map +1 -1
- package/dist/services/crud.service.d.ts +2 -2
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +16 -2
- package/dist/services/crud.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/services/crud-helper.service.ts +5 -0
- package/src/services/crud.service.ts +20 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidstarters/solid-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.36",
|
|
4
4
|
"description": "This module is a NestJS module containing all the required core providers required by a Solid application",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -312,6 +312,11 @@ export class CrudHelperService {
|
|
|
312
312
|
const matchingPermssions = activeUser.permissions.filter((p) => permissionNames.includes(p));
|
|
313
313
|
return matchingPermssions.length > 0
|
|
314
314
|
}
|
|
315
|
+
hasRecoverPermissionOnModel = (activeUser: ActiveUserData, modelName: string) => {
|
|
316
|
+
const permissionNames = [`${classify(modelName)}Controller.recover`, `${classify(modelName)}Controller.recoverMany`];
|
|
317
|
+
const matchingPermssions = activeUser.permissions.filter((p) => permissionNames.includes(p));
|
|
318
|
+
return matchingPermssions.length > 0
|
|
319
|
+
}
|
|
315
320
|
|
|
316
321
|
|
|
317
322
|
|
|
@@ -701,8 +701,17 @@ export class CRUDService<T> { //Add two generic value i.e Person,CreatePersonDto
|
|
|
701
701
|
// return removedEntities
|
|
702
702
|
}
|
|
703
703
|
|
|
704
|
-
async recover(id: number) {
|
|
704
|
+
async recover(id: number,solidRequestContext: any = {}) {
|
|
705
705
|
try {
|
|
706
|
+
const loadedmodel = await this.loadModel();
|
|
707
|
+
// Check wheather user has update permission for model
|
|
708
|
+
if (solidRequestContext.activeUser) {
|
|
709
|
+
const hasPermission = this.crudHelperService.hasRecoverPermissionOnModel(solidRequestContext.activeUser, loadedmodel.singularName);
|
|
710
|
+
if (!hasPermission) {
|
|
711
|
+
throw new BadRequestException('Forbidden');
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
706
715
|
const softDeletedRows = await this.repo.findOne({
|
|
707
716
|
where: {
|
|
708
717
|
//@ts-ignore
|
|
@@ -732,8 +741,17 @@ export class CRUDService<T> { //Add two generic value i.e Person,CreatePersonDto
|
|
|
732
741
|
}
|
|
733
742
|
}
|
|
734
743
|
|
|
735
|
-
async recoverMany(ids: number[]) {
|
|
744
|
+
async recoverMany(ids: number[],solidRequestContext: any = {}) {
|
|
736
745
|
try {
|
|
746
|
+
const loadedmodel = await this.loadModel();
|
|
747
|
+
// Check wheather user has update permission for model
|
|
748
|
+
if (solidRequestContext.activeUser) {
|
|
749
|
+
const hasPermission = this.crudHelperService.hasRecoverPermissionOnModel(solidRequestContext.activeUser, loadedmodel.singularName);
|
|
750
|
+
if (!hasPermission) {
|
|
751
|
+
throw new BadRequestException('Forbidden');
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
|
|
737
755
|
if (!ids || ids.length === 0) {
|
|
738
756
|
throw new Error("No IDs provided for recovery.");
|
|
739
757
|
}
|