1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-02 16:42:50 -05:00

reference OrganizationMembership instead

This commit is contained in:
Kyle Spearrin
2018-08-31 17:05:27 -04:00
parent b2d63b2383
commit 2562d5a40d
8 changed files with 54 additions and 61 deletions

View File

@ -46,35 +46,16 @@ namespace Bit.Core.Services
};
var orgAbilities = await _applicationCacheService.GetOrganizationAbilitiesAsync();
IEnumerable<IEvent> orgEvents;
if(_currentContext.UserId.HasValue)
{
orgEvents = _currentContext.Organizations
.Where(o => CanUseEvents(orgAbilities, o.Id))
.Select(o => new EventMessage(_currentContext)
{
OrganizationId = o.Id,
UserId = userId,
ActingUserId = userId,
Type = type,
Date = DateTime.UtcNow
});
}
else
{
var orgs = await _currentContext.OrganizationMembershipAsync(_organizationUserRepository, userId);
orgEvents = orgs
.Where(o => o.Status == OrganizationUserStatusType.Confirmed &&
CanUseEvents(orgAbilities, o.OrganizationId))
.Select(o => new EventMessage(_currentContext)
{
OrganizationId = o.OrganizationId,
UserId = userId,
ActingUserId = userId,
Type = type,
Date = DateTime.UtcNow
});
}
var orgs = await _currentContext.OrganizationMembershipAsync(_organizationUserRepository, userId);
var orgEvents = orgs.Where(o => CanUseEvents(orgAbilities, o.Id))
.Select(o => new EventMessage(_currentContext)
{
OrganizationId = o.Id,
UserId = userId,
ActingUserId = userId,
Type = type,
Date = DateTime.UtcNow
});
if(orgEvents.Any())
{