1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-01 08:02:49 -05:00

collection user refactor

This commit is contained in:
Kyle Spearrin
2017-05-11 14:52:35 -04:00
parent d7f9977382
commit 21d1cd6adc
43 changed files with 318 additions and 504 deletions

View File

@ -1,35 +0,0 @@
using System;
using Bit.Core.Models.Table;
using System.Collections.Generic;
using System.Linq;
namespace Bit.Core.Models.Api
{
public class CollectionUserCollectionRequestModel
{
public string UserId { get; set; }
public IEnumerable<Collection> Collections { get; set; }
public IEnumerable<CollectionUser> ToCollectionUsers()
{
return Collections.Select(c => new CollectionUser
{
OrganizationUserId = new Guid(UserId),
CollectionId = new Guid(c.CollectionId),
ReadOnly = c.ReadOnly
});
}
public class Collection
{
public string CollectionId { get; set; }
public bool ReadOnly { get; set; }
}
}
public class CollectionUserUserRequestModel
{
public string UserId { get; set; }
public bool ReadOnly { get; set; }
}
}

View File

@ -12,15 +12,6 @@ namespace Bit.Core.Models.Api
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

View File

@ -1,5 +1,4 @@
using System;
using Bit.Core.Models.Table;
using Bit.Core.Models.Data;
using Bit.Core.Enums;
@ -7,7 +6,7 @@ namespace Bit.Core.Models.Api
{
public class CollectionUserResponseModel : ResponseModel
{
public CollectionUserResponseModel(CollectionUserUserDetails collectionUser)
public CollectionUserResponseModel(CollectionUserDetails collectionUser)
: base("collectionUser")
{
if(collectionUser == null)
@ -15,9 +14,7 @@ namespace Bit.Core.Models.Api
throw new ArgumentNullException(nameof(collectionUser));
}
Id = collectionUser.Id?.ToString();
OrganizationUserId = collectionUser.OrganizationUserId.ToString();
CollectionId = collectionUser.CollectionId?.ToString();
AccessAll = collectionUser.AccessAll;
Name = collectionUser.Name;
Email = collectionUser.Email;
@ -26,9 +23,7 @@ namespace Bit.Core.Models.Api
ReadOnly = collectionUser.ReadOnly;
}
public string Id { get; set; }
public string OrganizationUserId { get; set; }
public string CollectionId { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }

View File

@ -6,7 +6,7 @@ namespace Bit.Core.Models.Api
{
public class GroupUserResponseModel : ResponseModel
{
public GroupUserResponseModel(GroupUserUserDetails groupUser)
public GroupUserResponseModel(GroupUserDetails groupUser)
: base("groupUser")
{
if(groupUser == null)
@ -15,7 +15,6 @@ namespace Bit.Core.Models.Api
}
OrganizationUserId = groupUser.OrganizationUserId.ToString();
GroupId = groupUser.GroupId.ToString();
AccessAll = groupUser.AccessAll;
Name = groupUser.Name;
Email = groupUser.Email;
@ -24,7 +23,6 @@ namespace Bit.Core.Models.Api
}
public string OrganizationUserId { get; set; }
public string GroupId { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }

View File

@ -2,15 +2,14 @@
namespace Bit.Core.Models.Data
{
public class GroupUserUserDetails
public class CollectionUserDetails
{
public Guid OrganizationUserId { get; set; }
public Guid OrganizationId { get; set; }
public Guid GroupId { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public Enums.OrganizationUserStatusType Status { get; set; }
public Enums.OrganizationUserType Type { get; set; }
public bool ReadOnly { get; set; }
}
}

View File

@ -2,17 +2,13 @@
namespace Bit.Core.Models.Data
{
public class CollectionUserUserDetails
public class GroupUserDetails
{
public Guid? Id { get; set; }
public Guid OrganizationUserId { get; set; }
public Guid? OrganizationId { get; set; }
public Guid? CollectionId { get; set; }
public bool AccessAll { get; set; }
public string Name { get; set; }
public string Email { get; set; }
public Enums.OrganizationUserStatusType Status { get; set; }
public Enums.OrganizationUserType Type { get; set; }
public bool ReadOnly { get; set; }
}
}

View File

@ -1,11 +0,0 @@
using System;
namespace Bit.Core.Models.Table
{
public class CollectionGroup
{
public Guid CollectionId { get; set; }
public Guid GroupId { get; set; }
public bool ReadOnly { get; set; }
}
}

View File

@ -1,20 +0,0 @@
using System;
using Bit.Core.Utilities;
namespace Bit.Core.Models.Table
{
public class CollectionUser : IDataObject<Guid>
{
public Guid Id { get; set; }
public Guid CollectionId { get; set; }
public Guid OrganizationUserId { get; set; }
public bool ReadOnly { get; set; }
public DateTime CreationDate { get; internal set; } = DateTime.UtcNow;
public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow;
public void SetNewId()
{
Id = CoreHelpers.GenerateComb();
}
}
}