Skip to content

Commit

Permalink
fix(core): createdon modifiedon can not be changed via input
Browse files Browse the repository at this point in the history
  • Loading branch information
yeshamavani committed Aug 30, 2024
1 parent adccfa5 commit 38908d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}
Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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);
}

Expand All @@ -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(
Expand All @@ -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);
}
}

0 comments on commit 38908d0

Please sign in to comment.