Perhaps I am missing some dependecies or configuration of dependency injection? Can you show which dependecies is used in the working example you presented?
I am experiencing the same problem in a project build on the startup template (eventhandler and dependant classes placed in the .Host project)
Project structure of RabbitMQ consumer implementation in a project based on startup template
Below is the full structure of our main project and the SensorData "microservice"
My issue is not solved by the solution mentioned in that link.
It seems like the endpoints from the organizationunitcontroller in the identity module has been duplicated after I made an override of the controller. The examples of calls to endpoints that originates from the identity modules is illustrated below along with the errors I receive:
localhost/api/identity/organization-units
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
Stella.Controllers.OrganizationUnits.AppOrganizationUnitController.GetListAsync (Stella.HttpApi)
Volo.Abp.Identity.OrganizationUnitController.GetListAsync (Volo.Abp.Identity.Pro.HttpApi)
localhost/api/identity/organization-units/{id}
Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints. Matches:
Stella.Controllers.OrganizationUnits.AppOrganizationUnitController.GetAsync (Stella.HttpApi)
Volo.Abp.Identity.OrganizationUnitController.GetAsync (Volo.Abp.Identity.Pro.HttpApi)
That seems to fix the problem, thank you.
Now my final issue is related to the controller routing, but this seems to be a known issue.
When overriding methods from a module controller like I have done with OrganizationUnitController it will create routing conflicts when any endpoints are called (even though I have not made changes to the virtual controller methods originating from the module) and throw an exception: "Microsoft.AspNetCore.Routing.Matching.AmbiguousMatchException: The request matched multiple endpoints".
Have you found a solution to this issue or is it planned as part of the 3.3 milestone?
I have implemented the following based on the solution you suggested:
public interface IAppOrganizationUnitRepository : IOrganizationUnitRepository
{
public Task<List<MonitoredObject>> GetMonitoredObjectsAsync(Guid organizationUnitId, CancellationToken cancellationToken = default);
}
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(EfCoreOrganizationUnitRepository), typeof(IAppOrganizationUnitRepository))]
public class EfCoreAppOrganizationUnitRepository : EfCoreOrganizationUnitRepository, IAppOrganizationUnitRepository
{
private readonly IDbContextProvider<StellaDbContext> _stellaDBContext;
public EfCoreAppOrganizationUnitRepository(IDbContextProvider<IIdentityDbContext> dbContextProvider, IDbContextProvider<StellaDbContext> stellaDbContext)
: base(dbContextProvider)
{
_stellaDBContext = stellaDbContext;
}
public async Task<List<MonitoredObject>> GetMonitoredObjectsAsync(
Guid organizationUnitId, CancellationToken cancellationToken = default)
{
var query = from organizationUnitMonitoredObjectLink in _stellaDBContext.GetDbContext().OrganizationUnitMonitoredObjectLinks
join monitoredObject in _stellaDBContext.GetDbContext().MonitoredObjects on organizationUnitMonitoredObjectLink.MonitoredObjectId equals monitoredObject.Id
where organizationUnitMonitoredObjectLink.MonitoredObjectId == organizationUnitId
select monitoredObject;
return await query.ToListAsync(GetCancellationToken(cancellationToken));
}
}
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(OrganizationUnitManager),typeof(IAppOrganizationUnitAppService))]
public class OrganizationUnitsAppService : OrganizationUnitAppService, IAppOrganizationUnitAppService
{
public OrganizationUnitsAppService(OrganizationUnitManager organizationUnitManager,
IdentityUserManager userManager,
IOrganizationUnitRepository organizationUnitRepository,
IIdentityUserRepository identityUserRepository,
IIdentityRoleRepository identityRoleRepository)
: base(organizationUnitManager, userManager, organizationUnitRepository, identityUserRepository, identityRoleRepository)
{
}
public async Task<List<MonitoredObjectDto>> GetMonitoredObjectsAsync(Guid id)
{
var monitoredObjects = await ((IAppOrganizationUnitRepository)OrganizationUnitRepository).GetMonitoredObjectsAsync(id);
return ObjectMapper.Map<List<MonitoredObject>,List<MonitoredObjectDto>>(monitoredObjects);
}
}
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(OrganizationUnitController),typeof(IAppOrganizationUnitAppService))]
public class AppOrganizationUnitController : OrganizationUnitController, IAppOrganizationUnitAppService
{
public AppOrganizationUnitController(IOrganizationUnitAppService organizationUnitAppService)
: base(organizationUnitAppService)
{
}
[HttpGet]
[Route("{id}/monitoredObjects")]
public Task<List<MonitoredObjectDto>> GetMonitoredObjectsAsync(Guid id)
{
return ((IAppOrganizationUnitAppService)OrganizationUnitAppService).GetMonitoredObjectsAsync(id);
}
}
However when I attempt to start the HttpApi.Host project I now get the following exception:
EvemtTypes- OrganizationUnitEventTypesLink
The properties (Geofences, Users, MonitoredObjects and EventTypes) I mentioned in my previous reply is part of my extension of the enitity OrganizationUnit which originates from the abp Identity Module, and act as navigation properties.
Repository extension - EfCoreOrganizationUnitRepository I wish to extend the EfCoreOrganizationUnitRepository that originates from the abp Identity Module and keep all of the methods implemented in the module but also extend the repository with some of my own like shown below (GetCustomersAsync and GetEventTypesAsync):
I expected that I could simply inherit from the module repository, inject my project's dbcontext and then use this in my own methods to get all EventTypes related to the specific OrganizationUnit for example.
AppService extension - OrganizationUnitAppService However when I attempt to make use of this repository I am not able to call any of the methods I defined because they are not defined in the IOrganizationUnitRepository from the Identity Module.
I would like to know how to extend the existing OrganizationUnitRepository in a way that makes it possible to use it in a AppService with the methods it already defines and those I have defined myself.
Thank you, that solves this part of my issue. I do find it a little odd though that the extended properties will be serialized into children of "ExtraProperties". That would suggest that these properties are stored as json in the database even though that is not the case.
Additionally, with my extended entity of Organization unit, which is related to the IdentityUser entity class, I also have a few navigation properties like below:
These navigation properties should be handled in a corresponding EF core repository class which of course already exist (EfCoreOrganizationUnitRepository) in the identity module. What is the procedure for overriding a repository class from the identity module and then using it in an overridden app service? I don't think the documentation covers this.
When adding a new sub unit to a organization tree, an error will occur that prevents the action from succeeding: Adding a new root unit to the organization tree will solve the issue momentarily until a user has re-entered the "Organization unit" page.
ABP Framework version: v3.1.0 UI type: Angular Browser: Chrome Tiered (MVC) or Identity Server Seperated (Angular): No
Setting a new password from the web GUI (in Administration --> Identity management --> Users) will log the password in plain text.
After setting the new password for a user, I am able to see it in the details of an audit log:
This log will of course also be present in the corresponding database table:
I consider this a critical security flaw - user passwords should never be stored as plaintext even if it is just in a log.
<br>
ABP Framework version: v3.1.0 UI type: Angular Tiered (MVC) or Identity Server Seperated (Angular): No
Using the ObjectExtensionManager in [ProjectName]ModuleExtensionConfigurator (in Domain.Shared) I have added the following:
However when I attempt to call the GetAsync method with a http client, I get an exception stating that IdentityUserDto can't be mapped to UserDto:
For reference, take a look at the App Service and UserDto class: IdentityUser App service override IdentityUser Dto override
Sometimes when a user logs out of the system the UserId and Username will not be logged in the abpscuritylogs table.
Example:
It has previously been noted that the issue will occur in the following scenarios:
However has also occured randomly for me outside of these scenarios in a session where I repeatedly login/logout (for the purpose of testing). I also find it it problematic that a UserId might not be logged if the user accidently presses the logout button twice.