You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally posted by jhuerta September 20, 2023
Hi,
I am trying to get some user information while doing some operations in the AuditableEntityInterceptor.cs
I notice that if I inject "IIdentityService identityService" in the constructor of AuditableEntityInterceptor, then the following code will freeze in DependencyInjection.cs:
options.AddInterceptors(sp.GetServices());
For what I observe, if I comment out this line in DependencyInjection.cs, then the code runs fine:
services.AddScoped<ISaveChangesInterceptor, AuditableEntityInterceptor>();
So my understanding is that something goes wrong when it tries to build the IdentityService for the IIdentityService interface in the AuditableEntityInterceptor.cs constructor.
Probably is something that I don't understand, maybe some circular dependency?
I had the same issue when I tried to inject IIdentityService in the constructor of CurrentUser.cs. In this case I was not able to generate and run migrations, it hangs at some point.
Any idea why I cannot use IIdentityService in AuditableEntityInterceptor or CurrentUser.cs?
#412 seems to be related but ICurrentUservice is now IUser. Here it mentions "Update: If you need the current user in any other command/query you can simply ask for an ICurrentUserService and for an IIdentityService using dependency injection and can access the user info with this." This is similar of what I want to do, but not in a command/query, but in the AuditableEntityInterceptor or in the IUser itself.
Thanks,
Juan
The text was updated successfully, but these errors were encountered:
@jhuerta I encountered a similar issue with wanting to inject user infomation into the db interceptor and could not do it with the IdentityService but my way around this was having the ICurrentUserService still in the Application layer but I placed the implementation in the Web API project and grabbed the current logged in user claims from the HTTP context. The below implementation allowed me to inject ICurrentUserService in the inceptor without any problems.
Discussed in #993
Originally posted by jhuerta September 20, 2023
Hi,
I am trying to get some user information while doing some operations in the AuditableEntityInterceptor.cs
I notice that if I inject "IIdentityService identityService" in the constructor of AuditableEntityInterceptor, then the following code will freeze in DependencyInjection.cs:
options.AddInterceptors(sp.GetServices());
For what I observe, if I comment out this line in DependencyInjection.cs, then the code runs fine:
services.AddScoped<ISaveChangesInterceptor, AuditableEntityInterceptor>();
So my understanding is that something goes wrong when it tries to build the IdentityService for the IIdentityService interface in the AuditableEntityInterceptor.cs constructor.
Probably is something that I don't understand, maybe some circular dependency?
I had the same issue when I tried to inject IIdentityService in the constructor of CurrentUser.cs. In this case I was not able to generate and run migrations, it hangs at some point.
Any idea why I cannot use IIdentityService in AuditableEntityInterceptor or CurrentUser.cs?
#412 seems to be related but ICurrentUservice is now IUser. Here it mentions "Update: If you need the current user in any other command/query you can simply ask for an ICurrentUserService and for an IIdentityService using dependency injection and can access the user info with this." This is similar of what I want to do, but not in a command/query, but in the AuditableEntityInterceptor or in the IUser itself.
Thanks,
Juan
The text was updated successfully, but these errors were encountered: