Refactor authorization folder structure
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
namespace Distribution.Infra.Authorization;
|
||||
|
||||
public class ScopeAccessService(IScopeRepository repo) : IScopeAccessService
|
||||
{
|
||||
public Task<bool> HasStoreScopeAsync(Guid userId, Guid storeId) =>
|
||||
repo.HasStoreScopeAsync(userId, storeId);
|
||||
|
||||
public Task<bool> HasRouteScopeAsync(Guid userId, Guid routeId) =>
|
||||
repo.HasRouteScopeAsync(userId, routeId);
|
||||
|
||||
public Task<bool> HasRegionScopeAsync(Guid userId, Guid regionId) =>
|
||||
repo.HasRegionScopeAsync(userId, regionId);
|
||||
|
||||
public async Task<List<Guid>> GetAccessibleStoreIdsAsync(Guid userId)
|
||||
{
|
||||
var directStoreIds = await repo.GetDirectStoreIdsAsync(userId);
|
||||
var routeIds = await repo.GetRouteIdsAsync(userId);
|
||||
var regionIds = await repo.GetRegionIdsAsync(userId);
|
||||
|
||||
var storeIdsViaRoute = await repo.GetStoreIdsByRouteIdsAsync(routeIds);
|
||||
var routeIdsViaRegion = await repo.GetRouteIdsByRegionIdsAsync(regionIds);
|
||||
var storeIdsViaRegion = await repo.GetStoreIdsByRouteIdsAsync(routeIdsViaRegion);
|
||||
|
||||
return directStoreIds
|
||||
.Concat(storeIdsViaRoute)
|
||||
.Concat(storeIdsViaRegion)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user