mirror of
https://github.com/bitwarden/server.git
synced 2025-06-30 23:52:50 -05:00
org user subvaults apis
This commit is contained in:
@ -7,6 +7,7 @@ namespace Bit.Core.Models.Api
|
||||
public class OrganizationUserInviteRequestModel
|
||||
{
|
||||
public string Email { get; set; }
|
||||
public IEnumerable<OrganizationUserSubvaultRequestModel> Subvaults { get; set; }
|
||||
}
|
||||
|
||||
public class OrganizationUserAcceptRequestModel
|
||||
@ -22,31 +23,35 @@ namespace Bit.Core.Models.Api
|
||||
public class OrganizationUserUpdateRequestModel
|
||||
{
|
||||
public Enums.OrganizationUserType Type { get; set; }
|
||||
public IEnumerable<Subvault> Subvaults { get; set; }
|
||||
public IEnumerable<OrganizationUserSubvaultRequestModel> Subvaults { get; set; }
|
||||
}
|
||||
|
||||
public class Subvault
|
||||
public class OrganizationUserSubvaultRequestModel
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string SubvaultId { get; set; }
|
||||
public bool Admin { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
public SubvaultUser ToSubvaultUser()
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string SubvaultId { get; set; }
|
||||
public bool Admin { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
|
||||
public SubvaultUser ToSubvaultUser()
|
||||
var subvault = new SubvaultUser
|
||||
{
|
||||
var user = new SubvaultUser
|
||||
{
|
||||
SubvaultId = new Guid(SubvaultId),
|
||||
Admin = Admin,
|
||||
ReadOnly = ReadOnly
|
||||
};
|
||||
Admin = Admin,
|
||||
ReadOnly = ReadOnly
|
||||
};
|
||||
|
||||
if(string.IsNullOrWhiteSpace(Id))
|
||||
{
|
||||
user.Id = new Guid(Id);
|
||||
}
|
||||
|
||||
return user;
|
||||
if(!string.IsNullOrWhiteSpace(SubvaultId))
|
||||
{
|
||||
subvault.SubvaultId = new Guid(SubvaultId);
|
||||
}
|
||||
|
||||
if(!string.IsNullOrWhiteSpace(Id))
|
||||
{
|
||||
subvault.Id = new Guid(Id);
|
||||
}
|
||||
|
||||
return subvault;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core.Models.Data;
|
||||
using System.Collections.Generic;
|
||||
using Bit.Core.Models.Table;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
@ -36,12 +35,13 @@ namespace Bit.Core.Models.Api
|
||||
public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel
|
||||
{
|
||||
public OrganizationUserDetailsResponseModel(OrganizationUserUserDetails organizationUser,
|
||||
IEnumerable<Subvault> subvaults)
|
||||
IEnumerable<SubvaultUserDetails> subvaults)
|
||||
: base(organizationUser, "organizationUserDetails")
|
||||
{
|
||||
Subvaults = new ListResponseModel<SubvaultResponseModel>(subvaults.Select(s => new SubvaultResponseModel(s)));
|
||||
Subvaults = new ListResponseModel<OrganizationUserSubvaultResponseModel>(
|
||||
subvaults.Select(s => new OrganizationUserSubvaultResponseModel(s)));
|
||||
}
|
||||
|
||||
public ListResponseModel<SubvaultResponseModel> Subvaults { get; set; }
|
||||
public ListResponseModel<OrganizationUserSubvaultResponseModel> Subvaults { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Bit.Core.Models.Data;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class OrganizationUserSubvaultResponseModel : ResponseModel
|
||||
{
|
||||
public OrganizationUserSubvaultResponseModel(SubvaultUserDetails details,
|
||||
string obj = "organizationUserSubvault")
|
||||
: base(obj)
|
||||
{
|
||||
if(details == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(details));
|
||||
}
|
||||
|
||||
Id = details.Id.ToString();
|
||||
Name = details.Name;
|
||||
SubvaultId = details.SubvaultId.ToString();
|
||||
ReadOnly = details.ReadOnly;
|
||||
Admin = details.Admin;
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string SubvaultId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool Admin { get; set; }
|
||||
}
|
||||
}
|
14
src/Core/Models/Data/SubvaultUserDetails.cs
Normal file
14
src/Core/Models/Data/SubvaultUserDetails.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace Bit.Core.Models.Data
|
||||
{
|
||||
public class SubvaultUserDetails
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid OrganizationUserId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public Guid SubvaultId { get; set; }
|
||||
public bool ReadOnly { get; set; }
|
||||
public bool Admin { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user