mirror of
https://github.com/bitwarden/server.git
synced 2025-04-05 13:08:17 -05:00
added parameter for excluded
This commit is contained in:
parent
ce036c5e16
commit
93cff6e283
@ -24,9 +24,9 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("domains")]
|
||||
public Task<DomainsResponseModel> GetDomains()
|
||||
public Task<DomainsResponseModel> GetDomains(bool excluded = true)
|
||||
{
|
||||
var response = new DomainsResponseModel(_currentContext.User);
|
||||
var response = new DomainsResponseModel(_currentContext.User, excluded);
|
||||
return Task.FromResult(response);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ namespace Bit.Api.Models
|
||||
{
|
||||
public class DomainsResponseModel : ResponseModel
|
||||
{
|
||||
public DomainsResponseModel(User user)
|
||||
public DomainsResponseModel(User user, bool excluded = true)
|
||||
: base("domains")
|
||||
{
|
||||
if(user == null)
|
||||
@ -23,9 +23,11 @@ namespace Bit.Api.Models
|
||||
var excludedGlobalEquivalentDomains = user.ExcludedGlobalEquivalentDomains != null ?
|
||||
JsonConvert.DeserializeObject<List<GlobalEquivalentDomainsType>>(user.ExcludedGlobalEquivalentDomains) : null;
|
||||
var globalDomains = new List<GlobalDomains>();
|
||||
foreach(var domain in Core.Utilities.EquivalentDomains.Global)
|
||||
var domainsToInclude = excluded ? Core.Utilities.EquivalentDomains.Global :
|
||||
Core.Utilities.EquivalentDomains.Global.Where(d => !excludedGlobalEquivalentDomains.Contains(d.Key));
|
||||
foreach(var domain in domainsToInclude)
|
||||
{
|
||||
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains));
|
||||
globalDomains.Add(new GlobalDomains(domain.Key, domain.Value, excludedGlobalEquivalentDomains, excluded));
|
||||
}
|
||||
GlobalEquivalentDomains = !globalDomains.Any() ? null : globalDomains;
|
||||
}
|
||||
@ -39,11 +41,12 @@ namespace Bit.Api.Models
|
||||
public GlobalDomains(
|
||||
GlobalEquivalentDomainsType globalDomain,
|
||||
IEnumerable<string> domains,
|
||||
IEnumerable<GlobalEquivalentDomainsType> excludedDomains)
|
||||
IEnumerable<GlobalEquivalentDomainsType> excludedDomains,
|
||||
bool excluded)
|
||||
{
|
||||
Type = globalDomain;
|
||||
Domains = domains;
|
||||
Excluded = excludedDomains?.Contains(globalDomain) ?? false;
|
||||
Excluded = excluded && (excludedDomains?.Contains(globalDomain) ?? false);
|
||||
}
|
||||
|
||||
public GlobalEquivalentDomainsType Type { get; set; }
|
||||
|
Loading…
x
Reference in New Issue
Block a user