mirror of
https://github.com/bitwarden/server.git
synced 2025-07-01 08:02:49 -05:00
SelectionReadOnly MERGE to CollectionGroup
This commit is contained in:
@ -13,7 +13,7 @@ namespace Bit.Core.Models.Api
|
||||
public string Name { get; set; }
|
||||
[Required]
|
||||
public bool? AccessAll { get; set; }
|
||||
public IEnumerable<string> CollectionIds { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||
|
||||
public Group ToGroup(Guid orgId)
|
||||
{
|
||||
|
@ -1,5 +1,4 @@
|
||||
using Bit.Core.Models.Table;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
@ -13,7 +12,7 @@ namespace Bit.Core.Models.Api
|
||||
[Required]
|
||||
public Enums.OrganizationUserType? Type { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserAcceptRequestModel
|
||||
@ -33,7 +32,7 @@ namespace Bit.Core.Models.Api
|
||||
[Required]
|
||||
public Enums.OrganizationUserType? Type { get; set; }
|
||||
public bool AccessAll { get; set; }
|
||||
public IEnumerable<OrganizationUserCollectionRequestModel> Collections { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyRequestModel> Collections { get; set; }
|
||||
|
||||
public OrganizationUser ToOrganizationUser(OrganizationUser existingUser)
|
||||
{
|
||||
@ -48,22 +47,4 @@ namespace Bit.Core.Models.Api
|
||||
[Required]
|
||||
public IEnumerable<string> GroupIds { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserCollectionRequestModel
|
||||
{
|
||||
[Required]
|
||||
public string CollectionId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
public CollectionUser ToCollectionUser()
|
||||
{
|
||||
var collection = new CollectionUser
|
||||
{
|
||||
ReadOnly = ReadOnly,
|
||||
CollectionId = new Guid(CollectionId)
|
||||
};
|
||||
|
||||
return collection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
src/Core/Models/Api/Request/SelectionReadOnlyRequestModel.cs
Normal file
33
src/Core/Models/Api/Request/SelectionReadOnlyRequestModel.cs
Normal file
@ -0,0 +1,33 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
using Bit.Core.Models.Table;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class SelectionReadOnlyRequestModel
|
||||
{
|
||||
[Required]
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
public CollectionUser ToCollectionUser()
|
||||
{
|
||||
return new CollectionUser
|
||||
{
|
||||
ReadOnly = ReadOnly,
|
||||
CollectionId = new Guid(Id)
|
||||
};
|
||||
}
|
||||
|
||||
public SelectionReadOnly ToSelectionReadOnly()
|
||||
{
|
||||
return new SelectionReadOnly
|
||||
{
|
||||
Id = new Guid(Id),
|
||||
ReadOnly = ReadOnly
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Data;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
@ -28,12 +30,12 @@ namespace Bit.Core.Models.Api
|
||||
|
||||
public class GroupDetailsResponseModel : GroupResponseModel
|
||||
{
|
||||
public GroupDetailsResponseModel(Group group, IEnumerable<Guid> collectionIds)
|
||||
public GroupDetailsResponseModel(Group group, IEnumerable<SelectionReadOnly> collections)
|
||||
: base(group, "groupDetails")
|
||||
{
|
||||
CollectionIds = collectionIds;
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
|
||||
public IEnumerable<Guid> CollectionIds { get; set; }
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -52,27 +52,10 @@ namespace Bit.Core.Models.Api
|
||||
IEnumerable<SelectionReadOnly> collections)
|
||||
: base(organizationUser, "organizationUserDetails")
|
||||
{
|
||||
Collections = collections.Select(c => new CollectionSelection(c));
|
||||
Collections = collections.Select(c => new SelectionReadOnlyResponseModel(c));
|
||||
}
|
||||
|
||||
public IEnumerable<CollectionSelection> Collections { get; set; }
|
||||
|
||||
public class CollectionSelection
|
||||
{
|
||||
public CollectionSelection(Data.SelectionReadOnly selection)
|
||||
{
|
||||
if(selection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
}
|
||||
|
||||
Id = selection.Id.ToString();
|
||||
ReadOnly = selection.ReadOnly;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
}
|
||||
public IEnumerable<SelectionReadOnlyResponseModel> Collections { get; set; }
|
||||
}
|
||||
public class OrganizationUserUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
|
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class SelectionReadOnlyResponseModel
|
||||
{
|
||||
public SelectionReadOnlyResponseModel(SelectionReadOnly selection)
|
||||
{
|
||||
if(selection == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(selection));
|
||||
}
|
||||
|
||||
Id = selection.Id.ToString();
|
||||
ReadOnly = selection.ReadOnly;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace Bit.Core.Models.Table
|
||||
public class CollectionGroup
|
||||
{
|
||||
public Guid CollectionId { get; set; }
|
||||
public Guid OrganizationUserId { get; set; }
|
||||
public Guid GroupId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user