From 38908d020ad585a7b840f4cc2006b055ae01046a Mon Sep 17 00:00:00 2001 From: Yesha Mavani Date: Fri, 30 Aug 2024 13:30:30 +0530 Subject: [PATCH] fix(core): createdon modifiedon can not be changed via input gh-2158 --- ...lt-transactional-user-modify-repository.base.ts | 14 ++++++++++++++ .../default-user-modify-crud.repository.base.ts | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/packages/core/src/repositories/default-transactional-user-modify-repository.base.ts b/packages/core/src/repositories/default-transactional-user-modify-repository.base.ts index ca30ae9a29..e8b0531487 100644 --- a/packages/core/src/repositories/default-transactional-user-modify-repository.base.ts +++ b/packages/core/src/repositories/default-transactional-user-modify-repository.base.ts @@ -41,6 +41,8 @@ export abstract class DefaultTransactionalUserModifyRepository< throw new HttpErrors.Forbidden(AuthErrorKeys.InvalidCredentials); } const uid = currentUser?.userTenantId ?? currentUser?.id; + delete entity.createdOn; + delete entity.modifiedOn; entity.createdBy = uid; entity.modifiedBy = uid; return super.create(entity, options); @@ -56,6 +58,8 @@ export abstract class DefaultTransactionalUserModifyRepository< entities.forEach(entity => { entity.createdBy = uid ?? ''; entity.modifiedBy = uid ?? ''; + delete entity.createdOn; + delete entity.modifiedOn; }); return super.createAll(entities, options); } @@ -67,6 +71,8 @@ export abstract class DefaultTransactionalUserModifyRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; entity.modifiedBy = uid; + delete entity.createdOn; + delete entity.modifiedOn; return super.save(entity, options); } @@ -77,6 +83,8 @@ export abstract class DefaultTransactionalUserModifyRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; entity.modifiedBy = uid; + delete entity.createdOn; + delete entity.modifiedOn; return super.update(entity, options); } @@ -92,6 +100,8 @@ export abstract class DefaultTransactionalUserModifyRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.updateAll(data, where, options); } @@ -107,6 +117,8 @@ export abstract class DefaultTransactionalUserModifyRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.updateById(id, data, options); } @@ -121,6 +133,8 @@ export abstract class DefaultTransactionalUserModifyRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.replaceById(id, data, options); } } diff --git a/packages/core/src/repositories/default-user-modify-crud.repository.base.ts b/packages/core/src/repositories/default-user-modify-crud.repository.base.ts index 43b6ca994d..b9c1b3d269 100644 --- a/packages/core/src/repositories/default-user-modify-crud.repository.base.ts +++ b/packages/core/src/repositories/default-user-modify-crud.repository.base.ts @@ -44,6 +44,8 @@ export class DefaultUserModifyCrudRepository< const uid = currentUser?.userTenantId ?? currentUser?.id; entity.createdBy = uid; entity.modifiedBy = uid; + delete entity.createdOn; + delete entity.modifiedOn; return super.create(entity, options); } @@ -57,6 +59,8 @@ export class DefaultUserModifyCrudRepository< entities.forEach(entity => { entity.createdBy = uid ?? ''; entity.modifiedBy = uid ?? ''; + delete entity.createdOn; + delete entity.modifiedOn; }); return super.createAll(entities, options); } @@ -68,6 +72,8 @@ export class DefaultUserModifyCrudRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; entity.modifiedBy = uid; + delete entity.createdOn; + delete entity.modifiedOn; return super.save(entity, options); } @@ -78,6 +84,8 @@ export class DefaultUserModifyCrudRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; entity.modifiedBy = uid; + delete entity.createdOn; + delete entity.modifiedOn; return super.update(entity, options); } @@ -93,6 +101,8 @@ export class DefaultUserModifyCrudRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.updateAll(data, where, options); } @@ -108,6 +118,8 @@ export class DefaultUserModifyCrudRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.updateById(id, data, options); } async replaceById( @@ -121,6 +133,8 @@ export class DefaultUserModifyCrudRepository< } const uid = currentUser?.userTenantId ?? currentUser?.id; data.modifiedBy = uid; + delete data.createdOn; + delete data.modifiedOn; return super.replaceById(id, data, options); } }