فهرست منبع

fix: Validate required payload is not null

Owen Diffey 1 سال پیش
والد
کامیت
b0125d74f6

+ 1 - 1
backend/src/modules/DataModule/CreateJob.ts

@@ -3,7 +3,7 @@ import DataModuleJob from "./DataModuleJob";
 
 export default abstract class CreateJob extends DataModuleJob {
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (typeof this._payload.query !== "object")

+ 1 - 1
backend/src/modules/DataModule/DeleteByIdJob.ts

@@ -4,7 +4,7 @@ import DataModuleJob from "./DataModuleJob";
 
 export default abstract class DeleteByIdJob extends DataModuleJob {
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (!isObjectIdOrHexString(this._payload._id))

+ 1 - 1
backend/src/modules/DataModule/FindByIdJob.ts

@@ -4,7 +4,7 @@ import DataModuleJob from "./DataModuleJob";
 
 export default abstract class FindByIdJob extends DataModuleJob {
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (!isObjectIdOrHexString(this._payload._id))

+ 1 - 1
backend/src/modules/DataModule/GetDataJob.ts

@@ -4,7 +4,7 @@ import { FilterType, GetData } from "./plugins/getData";
 
 export default abstract class GetDataJob extends DataModuleJob {
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (typeof this._payload.page !== "number")

+ 1 - 1
backend/src/modules/DataModule/UpdateByIdJob.ts

@@ -4,7 +4,7 @@ import DataModuleJob from "./DataModuleJob";
 
 export default abstract class UpdateByIdJob extends DataModuleJob {
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (!isObjectIdOrHexString(this._payload._id))

+ 1 - 1
backend/src/modules/DataModule/models/users/jobs/GetModelPermissions.ts

@@ -12,7 +12,7 @@ export default class GetModelPermissions extends DataModuleJob {
 	protected static _hasPermission = true;
 
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (typeof this._payload.modelName !== "string")

+ 1 - 1
backend/src/modules/EventsModule/jobs/Subscribe.ts

@@ -11,7 +11,7 @@ export default class Subscribe extends Job {
 	}
 
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (typeof this._payload.channel !== "string")

+ 1 - 1
backend/src/modules/EventsModule/jobs/SubscribeMany.ts

@@ -11,7 +11,7 @@ export default class SubscribeMany extends Job {
 	}
 
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (!Array.isArray(this._payload.channels))

+ 1 - 1
backend/src/modules/EventsModule/jobs/Unsubscribe.ts

@@ -11,7 +11,7 @@ export default class Unsubscribe extends Job {
 	}
 
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (typeof this._payload.channel !== "string")

+ 1 - 1
backend/src/modules/EventsModule/jobs/UnsubscribeMany.ts

@@ -11,7 +11,7 @@ export default class UnsubscribeMany extends Job {
 	}
 
 	protected override async _validate() {
-		if (typeof this._payload !== "object")
+		if (typeof this._payload !== "object" || this._payload === null)
 			throw new Error("Payload must be an object");
 
 		if (!Array.isArray(this._payload.channels))