1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-06 10:32:49 -05:00

Organization User Accepted Invite Email Notifications (#1465)

This commit is contained in:
Addison Beck
2021-07-16 13:49:27 -04:00
committed by GitHub
parent 7abb053914
commit 5ec37b96b4
12 changed files with 99 additions and 16 deletions

View File

@ -389,5 +389,21 @@ namespace Bit.Core.Repositories.EntityFramework
}
Task<ICollection<string>> IOrganizationUserRepository.SelectKnownEmailsAsync(Guid organizationId, IEnumerable<string> emails, bool onlyRegisteredUsers) => throw new NotImplementedException();
public async Task<IEnumerable<OrganizationUserUserDetails>> GetManyByMinimumRoleAsync(Guid organizationId, OrganizationUserType minRole)
{
using (var scope = ServiceScopeFactory.CreateScope())
{
var dbContext = GetDatabaseContext(scope);
var query = dbContext.OrganizationUsers
.Include(e => e.User)
.Where(e => e.OrganizationId.Equals(organizationId) && e.Type <= minRole)
.Select(e => new OrganizationUserUserDetails() {
Id = e.Id,
Email = e.Email ?? e.User.Email
});
return await query.ToListAsync();
}
}
}
}

View File

@ -37,5 +37,6 @@ namespace Bit.Core.Repositories
Task DeleteManyAsync(IEnumerable<Guid> userIds);
Task<OrganizationUser> GetByOrganizationEmailAsync(Guid organizationId, string email);
Task<IEnumerable<OrganizationUserPublicKey>> GetManyPublicKeysByOrganizationUserAsync(Guid organizationId, IEnumerable<Guid> Ids);
Task<IEnumerable<OrganizationUserUserDetails>> GetManyByMinimumRoleAsync(Guid organizationId, OrganizationUserType minRole);
}
}

View File

@ -391,5 +391,18 @@ namespace Bit.Core.Repositories.SqlServer
return results.ToList();
}
}
public async Task<IEnumerable<OrganizationUserUserDetails>> GetManyByMinimumRoleAsync(Guid organizationId, OrganizationUserType minRole)
{
using (var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<OrganizationUserUserDetails>(
"[dbo].[OrganizationUser_ReadByMinimumRole]",
new { OrganizationId = organizationId, MinRole = minRole },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
}
}