Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): createdon modifiedon can not be changed via input #2159

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
entity.createdOn = new Date();
entity.modifiedOn = new Date();
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 ?? '';
entity.createdOn = new Date();
entity.modifiedOn = new Date();
});
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;
yeshamavani marked this conversation as resolved.
Show resolved Hide resolved
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;
entity.createdOn = new Date();
entity.modifiedOn = new Date();
return super.create(entity, options);
}

Expand All @@ -57,6 +59,8 @@ export class DefaultUserModifyCrudRepository<
entities.forEach(entity => {
entity.createdBy = uid ?? '';
entity.modifiedBy = uid ?? '';
entity.createdOn = new Date();
entity.modifiedOn = new Date();
});
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);
}
}
Loading