I have one API which is called by external service and function in this service is AllowAnonymous. When user is calling this service we are taking user id as input to verify if user have rights to access the application, then on the service call we are updating one table in DB, I'm assigning LastModifierId as user id (which I received in input ) at the same time I'm assigning same user id in one more field (CCFLastModifierId), after successful update I found CCFLastModifierId is updated in DB but LastModifierId is not updating. Could you please help to understand the reason and how can I solve this problem.
I tried to assign the value by
- ObjectHelper.TrySetProperty(fc, x => x.LastModifierId, () => user.Id);
- tablename.LastModifierId= user.Id;
Both are not working.
ABP Framework version: v5.3.2
UI Type:React
Database System: EF Core (SQL Server)
Tiered (for MVC) or Auth Server Separated (for Angular): yes
Exception message and full stack trace:NA Call AllowAnonymous function from 3rd party and update few columns in table.
2 Answer(s)
-
0
Hi,
Because ABP uses the CurrentUser.Id as the
LastModifierId
value.You can try:
private ICurrentPrincipalAccessor _currentPrincipalAccessor; .... var claims = new List<Claim>(){ new Claim(AbpClaimTypes.UserId,user.Id)}; using(_currentPrincipalAccessor.Change(claims)) { _repository.UpdateAsync(..., autoSave: true) }
-
0
Hi,
Because ABP uses the CurrentUser.Id as the
LastModifierId
value.You can try:
private ICurrentPrincipalAccessor _currentPrincipalAccessor; .... var claims = new List<Claim>(){ new Claim(AbpClaimTypes.UserId,user.Id)}; using(_currentPrincipalAccessor.Change(claims)) { _repository.UpdateAsync(..., autoSave: true) }
Thank you. It is updating now.