diff --git a/src/Api/Controllers/CiphersController.cs b/src/Api/Controllers/CiphersController.cs index 6d21d8d758..59e3989d9e 100644 --- a/src/Api/Controllers/CiphersController.cs +++ b/src/Api/Controllers/CiphersController.cs @@ -17,7 +17,7 @@ namespace Bit.Api.Controllers { private readonly ICipherRepository _cipherRepository; private readonly IFolderRepository _folderRepository; - private readonly ISubvaultCipherRepository _subvaultCipherRepository; + private readonly ICollectionCipherRepository _collectionCipherRepository; private readonly ICipherService _cipherService; private readonly IUserService _userService; private readonly CurrentContext _currentContext; @@ -25,14 +25,14 @@ namespace Bit.Api.Controllers public CiphersController( ICipherRepository cipherRepository, IFolderRepository folderRepository, - ISubvaultCipherRepository subvaultCipherRepository, + ICollectionCipherRepository collectionCipherRepository, ICipherService cipherService, IUserService userService, CurrentContext currentContext) { _cipherRepository = cipherRepository; _folderRepository = folderRepository; - _subvaultCipherRepository = subvaultCipherRepository; + _collectionCipherRepository = collectionCipherRepository; _cipherService = cipherService; _userService = userService; _currentContext = currentContext; @@ -62,8 +62,8 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - var subvaultCiphers = await _subvaultCipherRepository.GetManyByUserIdCipherIdAsync(userId, cipherId); - return new CipherFullDetailsResponseModel(cipher, subvaultCiphers); + var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdCipherIdAsync(userId, cipherId); + return new CipherFullDetailsResponseModel(cipher, collectionCiphers); } [HttpGet("")] @@ -91,20 +91,20 @@ namespace Bit.Api.Controllers } [HttpGet("details")] - public async Task> GetSubvaults() + public async Task> GetCollections() { var userId = _userService.GetProperUserId(User).Value; - var ciphers = await _cipherRepository.GetManyByUserIdHasSubvaultsAsync(userId); + var ciphers = await _cipherRepository.GetManyByUserIdHasCollectionsAsync(userId); - var subvaultCiphers = await _subvaultCipherRepository.GetManyByUserIdAsync(userId); - var subvaultCiphersGroupDict = subvaultCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key); + var collectionCiphers = await _collectionCipherRepository.GetManyByUserIdAsync(userId); + var collectionCiphersGroupDict = collectionCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key); - var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, subvaultCiphersGroupDict)); + var responses = ciphers.Select(c => new CipherDetailsResponseModel(c, collectionCiphersGroupDict)); return new ListResponseModel(responses); } [HttpGet("organization-details")] - public async Task> GetOrganizationSubvaults(string organizationId) + public async Task> GetOrganizationCollections(string organizationId) { var userId = _userService.GetProperUserId(User).Value; var orgIdGuid = new Guid(organizationId); @@ -115,10 +115,10 @@ namespace Bit.Api.Controllers var ciphers = await _cipherRepository.GetManyByOrganizationIdAsync(orgIdGuid); - var subvaultCiphers = await _subvaultCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid); - var subvaultCiphersGroupDict = subvaultCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key); + var collectionCiphers = await _collectionCipherRepository.GetManyByOrganizationIdAsync(orgIdGuid); + var collectionCiphersGroupDict = collectionCiphers.GroupBy(s => s.CipherId).ToDictionary(s => s.Key); - var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, subvaultCiphersGroupDict)); + var responses = ciphers.Select(c => new CipherMiniDetailsResponseModel(c, collectionCiphersGroupDict)); return new ListResponseModel(responses); } @@ -179,12 +179,12 @@ namespace Bit.Api.Controllers } await _cipherService.ShareAsync(model.Cipher.ToCipher(cipher), new Guid(model.Cipher.OrganizationId), - model.SubvaultIds.Select(s => new Guid(s)), userId); + model.CollectionIds.Select(s => new Guid(s)), userId); } - [HttpPut("{id}/subvaults")] - [HttpPost("{id}/subvaults")] - public async Task PutSubvaults(string id, [FromBody]CipherSubvaultsRequestModel model) + [HttpPut("{id}/collections")] + [HttpPost("{id}/collections")] + public async Task PutCollections(string id, [FromBody]CipherCollectionsRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId); @@ -194,12 +194,12 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - await _cipherService.SaveSubvaultsAsync(cipher, model.SubvaultIds.Select(s => new Guid(s)), userId, false); + await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(s => new Guid(s)), userId, false); } - [HttpPut("{id}/subvaults-admin")] - [HttpPost("{id}/subvaults-admin")] - public async Task PutSubvaultsAdmin(string id, [FromBody]CipherSubvaultsRequestModel model) + [HttpPut("{id}/collections-admin")] + [HttpPost("{id}/collections-admin")] + public async Task PutCollectionsAdmin(string id, [FromBody]CipherCollectionsRequestModel model) { var userId = _userService.GetProperUserId(User).Value; var cipher = await _cipherRepository.GetByIdAsync(new Guid(id)); @@ -209,7 +209,7 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - await _cipherService.SaveSubvaultsAsync(cipher, model.SubvaultIds.Select(s => new Guid(s)), userId, true); + await _cipherService.SaveCollectionsAsync(cipher, model.CollectionIds.Select(s => new Guid(s)), userId, true); } [HttpDelete("{id}")] diff --git a/src/Api/Controllers/OrganizationUsersController.cs b/src/Api/Controllers/OrganizationUsersController.cs index 8bd173467b..2c25fffd1d 100644 --- a/src/Api/Controllers/OrganizationUsersController.cs +++ b/src/Api/Controllers/OrganizationUsersController.cs @@ -18,7 +18,7 @@ namespace Bit.Api.Controllers private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; private readonly IOrganizationService _organizationService; - private readonly ISubvaultRepository _subvaultRepository; + private readonly ICollectionRepository _collectionRepository; private readonly IUserService _userService; private readonly CurrentContext _currentContext; @@ -26,14 +26,14 @@ namespace Bit.Api.Controllers IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, IOrganizationService organizationService, - ISubvaultRepository subvaultRepository, + ICollectionRepository collectionRepository, IUserService userService, CurrentContext currentContext) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; _organizationService = organizationService; - _subvaultRepository = subvaultRepository; + _collectionRepository = collectionRepository; _userService = userService; _currentContext = currentContext; } @@ -75,7 +75,7 @@ namespace Bit.Api.Controllers var userId = _userService.GetProperUserId(User); var result = await _organizationService.InviteUserAsync(orgGuidId, userId.Value, model.Email, model.Type.Value, - model.AccessAllSubvaults, model.Subvaults?.Select(s => s.ToSubvaultUser())); + model.AccessAllCollections, model.Collections?.Select(s => s.ToCollectionUser())); } [HttpPut("{id}/reinvite")] @@ -132,7 +132,7 @@ namespace Bit.Api.Controllers var userId = _userService.GetProperUserId(User); await _organizationService.SaveUserAsync(model.ToOrganizationUser(organizationUser), userId.Value, - model.Subvaults?.Select(s => s.ToSubvaultUser())); + model.Collections?.Select(s => s.ToCollectionUser())); } [HttpDelete("{id}")] diff --git a/src/Api/Controllers/SubvaultUsersController.cs b/src/Api/Controllers/SubvaultUsersController.cs index fa90c2ac63..192b2a48ac 100644 --- a/src/Api/Controllers/SubvaultUsersController.cs +++ b/src/Api/Controllers/SubvaultUsersController.cs @@ -11,59 +11,59 @@ using Bit.Core; namespace Bit.Api.Controllers { - [Route("organizations/{orgId}/subvaultUsers")] + [Route("organizations/{orgId}/collectionUsers")] [Authorize("Application")] - public class SubvaultUsersController : Controller + public class CollectionUsersController : Controller { - private readonly ISubvaultRepository _subvaultRepository; - private readonly ISubvaultUserRepository _subvaultUserRepository; + private readonly ICollectionRepository _collectionRepository; + private readonly ICollectionUserRepository _collectionUserRepository; private readonly IUserService _userService; private readonly CurrentContext _currentContext; - public SubvaultUsersController( - ISubvaultRepository subvaultRepository, - ISubvaultUserRepository subvaultUserRepository, + public CollectionUsersController( + ICollectionRepository collectionRepository, + ICollectionUserRepository collectionUserRepository, IUserService userService, CurrentContext currentContext) { - _subvaultRepository = subvaultRepository; - _subvaultUserRepository = subvaultUserRepository; + _collectionRepository = collectionRepository; + _collectionUserRepository = collectionUserRepository; _userService = userService; _currentContext = currentContext; } - [HttpGet("{subvaultId}")] - public async Task> GetBySubvault(string orgId, string subvaultId) + [HttpGet("{collectionId}")] + public async Task> GetByCollection(string orgId, string collectionId) { - var subvaultIdGuid = new Guid(subvaultId); - var subvault = await _subvaultRepository.GetByIdAsync(subvaultIdGuid); - if(subvault == null || !_currentContext.OrganizationAdmin(subvault.OrganizationId)) + var collectionIdGuid = new Guid(collectionId); + var collection = await _collectionRepository.GetByIdAsync(collectionIdGuid); + if(collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId)) { throw new NotFoundException(); } - var subvaultUsers = await _subvaultUserRepository.GetManyDetailsBySubvaultIdAsync(subvaultIdGuid); - var responses = subvaultUsers.Select(s => new SubvaultUserResponseModel(s)); - return new ListResponseModel(responses); + var collectionUsers = await _collectionUserRepository.GetManyDetailsByCollectionIdAsync(collectionIdGuid); + var responses = collectionUsers.Select(s => new CollectionUserResponseModel(s)); + return new ListResponseModel(responses); } [HttpDelete("{id}")] [HttpPost("{id}/delete")] public async Task Delete(string orgId, string id) { - var user = await _subvaultUserRepository.GetByIdAsync(new Guid(id)); + var user = await _collectionUserRepository.GetByIdAsync(new Guid(id)); if(user == null) { throw new NotFoundException(); } - var subvault = await _subvaultRepository.GetByIdAsync(user.SubvaultId); - if(subvault == null || !_currentContext.OrganizationAdmin(subvault.OrganizationId)) + var collection = await _collectionRepository.GetByIdAsync(user.CollectionId); + if(collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId)) { throw new NotFoundException(); } - await _subvaultUserRepository.DeleteAsync(user); + await _collectionUserRepository.DeleteAsync(user); } } } diff --git a/src/Api/Controllers/SubvaultsController.cs b/src/Api/Controllers/SubvaultsController.cs index 5c0beea805..37dbd0365c 100644 --- a/src/Api/Controllers/SubvaultsController.cs +++ b/src/Api/Controllers/SubvaultsController.cs @@ -11,41 +11,41 @@ using Bit.Core; namespace Bit.Api.Controllers { - [Route("organizations/{orgId}/subvaults")] + [Route("organizations/{orgId}/collections")] [Authorize("Application")] - public class SubvaultsController : Controller + public class CollectionsController : Controller { - private readonly ISubvaultRepository _subvaultRepository; - private readonly ISubvaultService _subvaultService; + private readonly ICollectionRepository _collectionRepository; + private readonly ICollectionService _collectionService; private readonly IUserService _userService; private readonly CurrentContext _currentContext; - public SubvaultsController( - ISubvaultRepository subvaultRepository, - ISubvaultService subvaultService, + public CollectionsController( + ICollectionRepository collectionRepository, + ICollectionService collectionService, IUserService userService, CurrentContext currentContext) { - _subvaultRepository = subvaultRepository; - _subvaultService = subvaultService; + _collectionRepository = collectionRepository; + _collectionService = collectionService; _userService = userService; _currentContext = currentContext; } [HttpGet("{id}")] - public async Task Get(string orgId, string id) + public async Task Get(string orgId, string id) { - var subvault = await _subvaultRepository.GetByIdAsync(new Guid(id)); - if(subvault == null || !_currentContext.OrganizationAdmin(subvault.OrganizationId)) + var collection = await _collectionRepository.GetByIdAsync(new Guid(id)); + if(collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId)) { throw new NotFoundException(); } - return new SubvaultResponseModel(subvault); + return new CollectionResponseModel(collection); } [HttpGet("")] - public async Task> Get(string orgId) + public async Task> Get(string orgId) { var orgIdGuid = new Guid(orgId); if(!_currentContext.OrganizationAdmin(orgIdGuid)) @@ -53,21 +53,21 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - var subvaults = await _subvaultRepository.GetManyByOrganizationIdAsync(orgIdGuid); - var responses = subvaults.Select(s => new SubvaultResponseModel(s)); - return new ListResponseModel(responses); + var collections = await _collectionRepository.GetManyByOrganizationIdAsync(orgIdGuid); + var responses = collections.Select(s => new CollectionResponseModel(s)); + return new ListResponseModel(responses); } - [HttpGet("~/subvaults")] - public async Task> GetUser() + [HttpGet("~/collections")] + public async Task> GetUser() { - var subvaults = await _subvaultRepository.GetManyByUserIdAsync(_userService.GetProperUserId(User).Value); - var responses = subvaults.Select(s => new SubvaultResponseModel(s)); - return new ListResponseModel(responses); + var collections = await _collectionRepository.GetManyByUserIdAsync(_userService.GetProperUserId(User).Value); + var responses = collections.Select(s => new CollectionResponseModel(s)); + return new ListResponseModel(responses); } [HttpPost("")] - public async Task Post(string orgId, [FromBody]SubvaultRequestModel model) + public async Task Post(string orgId, [FromBody]CollectionRequestModel model) { var orgIdGuid = new Guid(orgId); if(!_currentContext.OrganizationAdmin(orgIdGuid)) @@ -75,36 +75,36 @@ namespace Bit.Api.Controllers throw new NotFoundException(); } - var subvault = model.ToSubvault(orgIdGuid); - await _subvaultService.SaveAsync(subvault); - return new SubvaultResponseModel(subvault); + var collection = model.ToCollection(orgIdGuid); + await _collectionService.SaveAsync(collection); + return new CollectionResponseModel(collection); } [HttpPut("{id}")] [HttpPost("{id}")] - public async Task Put(string orgId, string id, [FromBody]SubvaultRequestModel model) + public async Task Put(string orgId, string id, [FromBody]CollectionRequestModel model) { - var subvault = await _subvaultRepository.GetByIdAsync(new Guid(id)); - if(subvault == null || !_currentContext.OrganizationAdmin(subvault.OrganizationId)) + var collection = await _collectionRepository.GetByIdAsync(new Guid(id)); + if(collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId)) { throw new NotFoundException(); } - await _subvaultService.SaveAsync(model.ToSubvault(subvault)); - return new SubvaultResponseModel(subvault); + await _collectionService.SaveAsync(model.ToCollection(collection)); + return new CollectionResponseModel(collection); } [HttpDelete("{id}")] [HttpPost("{id}/delete")] public async Task Delete(string orgId, string id) { - var subvault = await _subvaultRepository.GetByIdAsync(new Guid(id)); - if(subvault == null || !_currentContext.OrganizationAdmin(subvault.OrganizationId)) + var collection = await _collectionRepository.GetByIdAsync(new Guid(id)); + if(collection == null || !_currentContext.OrganizationAdmin(collection.OrganizationId)) { throw new NotFoundException(); } - await _subvaultRepository.DeleteAsync(subvault); + await _collectionRepository.DeleteAsync(collection); } } } diff --git a/src/Core/Models/Api/Request/CipherRequestModel.cs b/src/Core/Models/Api/Request/CipherRequestModel.cs index 5fb2512b7d..5e7ee966d6 100644 --- a/src/Core/Models/Api/Request/CipherRequestModel.cs +++ b/src/Core/Models/Api/Request/CipherRequestModel.cs @@ -64,7 +64,7 @@ namespace Bit.Core.Models.Api public class CipherShareRequestModel : IValidatableObject { [Required] - public IEnumerable SubvaultIds { get; set; } + public IEnumerable CollectionIds { get; set; } [Required] public CipherRequestModel Cipher { get; set; } @@ -76,17 +76,17 @@ namespace Bit.Core.Models.Api new string[] { nameof(Cipher.OrganizationId) }); } - if(!SubvaultIds?.Any() ?? false) + if(!CollectionIds?.Any() ?? false) { - yield return new ValidationResult("You must select at least one subvault.", - new string[] { nameof(SubvaultIds) }); + yield return new ValidationResult("You must select at least one collection.", + new string[] { nameof(CollectionIds) }); } } } - public class CipherSubvaultsRequestModel + public class CipherCollectionsRequestModel { [Required] - public IEnumerable SubvaultIds { get; set; } + public IEnumerable CollectionIds { get; set; } } } diff --git a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs index c0bd953ea8..6a54cd5b29 100644 --- a/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs +++ b/src/Core/Models/Api/Request/Organizations/OrganizationUserRequestModels.cs @@ -12,8 +12,8 @@ namespace Bit.Core.Models.Api public string Email { get; set; } [Required] public Enums.OrganizationUserType? Type { get; set; } - public bool AccessAllSubvaults { get; set; } - public IEnumerable Subvaults { get; set; } + public bool AccessAllCollections { get; set; } + public IEnumerable Collections { get; set; } } public class OrganizationUserAcceptRequestModel @@ -32,32 +32,32 @@ namespace Bit.Core.Models.Api { [Required] public Enums.OrganizationUserType? Type { get; set; } - public bool AccessAllSubvaults { get; set; } - public IEnumerable Subvaults { get; set; } + public bool AccessAllCollections { get; set; } + public IEnumerable Collections { get; set; } public OrganizationUser ToOrganizationUser(OrganizationUser existingUser) { existingUser.Type = Type.Value; - existingUser.AccessAllSubvaults = AccessAllSubvaults; + existingUser.AccessAllCollections = AccessAllCollections; return existingUser; } } - public class OrganizationUserSubvaultRequestModel + public class OrganizationUserCollectionRequestModel { [Required] - public string SubvaultId { get; set; } + public string CollectionId { get; set; } public bool ReadOnly { get; set; } - public SubvaultUser ToSubvaultUser() + public CollectionUser ToCollectionUser() { - var subvault = new SubvaultUser + var collection = new CollectionUser { ReadOnly = ReadOnly, - SubvaultId = new Guid(SubvaultId) + CollectionId = new Guid(CollectionId) }; - return subvault; + return collection; } } } diff --git a/src/Core/Models/Api/Request/SubvaultRequestModel.cs b/src/Core/Models/Api/Request/SubvaultRequestModel.cs index 312e89e31d..1065361afc 100644 --- a/src/Core/Models/Api/Request/SubvaultRequestModel.cs +++ b/src/Core/Models/Api/Request/SubvaultRequestModel.cs @@ -6,25 +6,25 @@ using Newtonsoft.Json; namespace Bit.Core.Models.Api { - public class SubvaultRequestModel + public class CollectionRequestModel { [Required] [EncryptedString] [StringLength(300)] public string Name { get; set; } - public Subvault ToSubvault(Guid orgId) + public Collection ToCollection(Guid orgId) { - return ToSubvault(new Subvault + return ToCollection(new Collection { OrganizationId = orgId }); } - public Subvault ToSubvault(Subvault existingSubvault) + public Collection ToCollection(Collection existingCollection) { - existingSubvault.Name = Name; - return existingSubvault; + existingCollection.Name = Name; + return existingCollection; } } } diff --git a/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs b/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs index 9245965abc..4114b07bc4 100644 --- a/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs +++ b/src/Core/Models/Api/Request/SubvaultUserRequestModel.cs @@ -5,29 +5,29 @@ using System.Linq; namespace Bit.Core.Models.Api { - public class SubvaultUserSubvaultRequestModel + public class CollectionUserCollectionRequestModel { public string UserId { get; set; } - public IEnumerable Subvaults { get; set; } + public IEnumerable Collections { get; set; } - public IEnumerable ToSubvaultUsers() + public IEnumerable ToCollectionUsers() { - return Subvaults.Select(s => new SubvaultUser + return Collections.Select(s => new CollectionUser { OrganizationUserId = new Guid(UserId), - SubvaultId = new Guid(s.SubvaultId), + CollectionId = new Guid(s.CollectionId), ReadOnly = s.ReadOnly }); } - public class Subvault + public class Collection { - public string SubvaultId { get; set; } + public string CollectionId { get; set; } public bool ReadOnly { get; set; } } } - public class SubvaultUserUserRequestModel + public class CollectionUserUserRequestModel { public string UserId { get; set; } public bool ReadOnly { get; set; } diff --git a/src/Core/Models/Api/Response/CipherResponseModel.cs b/src/Core/Models/Api/Response/CipherResponseModel.cs index d2a8234456..95566868e3 100644 --- a/src/Core/Models/Api/Response/CipherResponseModel.cs +++ b/src/Core/Models/Api/Response/CipherResponseModel.cs @@ -74,52 +74,52 @@ namespace Bit.Core.Models.Api public class CipherDetailsResponseModel : CipherResponseModel { public CipherDetailsResponseModel(CipherDetails cipher, - IDictionary> subvaultCiphers, string obj = "cipherDetails") + IDictionary> collectionCiphers, string obj = "cipherDetails") : base(cipher, obj) { - if(subvaultCiphers.ContainsKey(cipher.Id)) + if(collectionCiphers.ContainsKey(cipher.Id)) { - SubvaultIds = subvaultCiphers[cipher.Id].Select(s => s.SubvaultId); + CollectionIds = collectionCiphers[cipher.Id].Select(s => s.CollectionId); } else { - SubvaultIds = new Guid[] { }; + CollectionIds = new Guid[] { }; } } - public CipherDetailsResponseModel(CipherDetails cipher, IEnumerable subvaultCiphers, + public CipherDetailsResponseModel(CipherDetails cipher, IEnumerable collectionCiphers, string obj = "cipherDetails") : base(cipher, obj) { - SubvaultIds = subvaultCiphers.Select(s => s.SubvaultId); + CollectionIds = collectionCiphers.Select(s => s.CollectionId); } - public IEnumerable SubvaultIds { get; set; } + public IEnumerable CollectionIds { get; set; } } public class CipherMiniDetailsResponseModel : CipherMiniResponseModel { public CipherMiniDetailsResponseModel(Cipher cipher, - IDictionary> subvaultCiphers, string obj = "cipherMiniDetails") + IDictionary> collectionCiphers, string obj = "cipherMiniDetails") : base(cipher, obj) { - if(subvaultCiphers.ContainsKey(cipher.Id)) + if(collectionCiphers.ContainsKey(cipher.Id)) { - SubvaultIds = subvaultCiphers[cipher.Id].Select(s => s.SubvaultId); + CollectionIds = collectionCiphers[cipher.Id].Select(s => s.CollectionId); } else { - SubvaultIds = new Guid[] { }; + CollectionIds = new Guid[] { }; } } - public IEnumerable SubvaultIds { get; set; } + public IEnumerable CollectionIds { get; set; } } public class CipherFullDetailsResponseModel : CipherDetailsResponseModel { - public CipherFullDetailsResponseModel(CipherFullDetails cipher, IEnumerable subvaultCiphers) - : base(cipher, subvaultCiphers, "cipherFullDetails") + public CipherFullDetailsResponseModel(CipherFullDetails cipher, IEnumerable collectionCiphers) + : base(cipher, collectionCiphers, "cipherFullDetails") { Edit = cipher.Edit; } diff --git a/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs b/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs index 43f99cb06a..1c9ce1dfe7 100644 --- a/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs +++ b/src/Core/Models/Api/Response/OrganizationUserResponseModel.cs @@ -22,7 +22,7 @@ namespace Bit.Core.Models.Api Email = organizationUser.Email; Type = organizationUser.Type; Status = organizationUser.Status; - AccessAllSubvaults = organizationUser.AccessAllSubvaults; + AccessAllCollections = organizationUser.AccessAllCollections; } public string Id { get; set; } @@ -31,19 +31,19 @@ namespace Bit.Core.Models.Api public string Email { get; set; } public OrganizationUserType Type { get; set; } public OrganizationUserStatusType Status { get; set; } - public bool AccessAllSubvaults { get; set; } + public bool AccessAllCollections { get; set; } } public class OrganizationUserDetailsResponseModel : OrganizationUserResponseModel { public OrganizationUserDetailsResponseModel(OrganizationUserUserDetails organizationUser, - IEnumerable subvaults) + IEnumerable collections) : base(organizationUser, "organizationUserDetails") { - Subvaults = new ListResponseModel( - subvaults.Select(s => new OrganizationUserSubvaultResponseModel(s))); + Collections = new ListResponseModel( + collections.Select(s => new OrganizationUserCollectionResponseModel(s))); } - public ListResponseModel Subvaults { get; set; } + public ListResponseModel Collections { get; set; } } } diff --git a/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs b/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs index 9a5299f16b..108be45255 100644 --- a/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs +++ b/src/Core/Models/Api/Response/OrganizationUserSubvaultResponseModel.cs @@ -3,10 +3,10 @@ using Bit.Core.Models.Data; namespace Bit.Core.Models.Api { - public class OrganizationUserSubvaultResponseModel : ResponseModel + public class OrganizationUserCollectionResponseModel : ResponseModel { - public OrganizationUserSubvaultResponseModel(SubvaultUserSubvaultDetails details, - string obj = "organizationUserSubvault") + public OrganizationUserCollectionResponseModel(CollectionUserCollectionDetails details, + string obj = "organizationUserCollection") : base(obj) { if(details == null) @@ -16,13 +16,13 @@ namespace Bit.Core.Models.Api Id = details.Id.ToString(); Name = details.Name; - SubvaultId = details.SubvaultId.ToString(); + CollectionId = details.CollectionId.ToString(); ReadOnly = details.ReadOnly; } public string Id { get; set; } public string Name { get; set; } - public string SubvaultId { get; set; } + public string CollectionId { get; set; } public bool ReadOnly { get; set; } } } diff --git a/src/Core/Models/Api/Response/SubvaultResponseModel.cs b/src/Core/Models/Api/Response/SubvaultResponseModel.cs index 436182a33d..501c20335c 100644 --- a/src/Core/Models/Api/Response/SubvaultResponseModel.cs +++ b/src/Core/Models/Api/Response/SubvaultResponseModel.cs @@ -3,19 +3,19 @@ using Bit.Core.Models.Table; namespace Bit.Core.Models.Api { - public class SubvaultResponseModel : ResponseModel + public class CollectionResponseModel : ResponseModel { - public SubvaultResponseModel(Subvault subvault) - : base("subvault") + public CollectionResponseModel(Collection collection) + : base("collection") { - if(subvault == null) + if(collection == null) { - throw new ArgumentNullException(nameof(subvault)); + throw new ArgumentNullException(nameof(collection)); } - Id = subvault.Id.ToString(); - OrganizationId = subvault.OrganizationId.ToString(); - Name = subvault.Name; + Id = collection.Id.ToString(); + OrganizationId = collection.OrganizationId.ToString(); + Name = collection.Name; } public string Id { get; set; } diff --git a/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs b/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs index c99f9bf9b6..4bc1798ac6 100644 --- a/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs +++ b/src/Core/Models/Api/Response/SubvaultUserResponseModel.cs @@ -5,31 +5,31 @@ using Bit.Core.Enums; namespace Bit.Core.Models.Api { - public class SubvaultUserResponseModel : ResponseModel + public class CollectionUserResponseModel : ResponseModel { - public SubvaultUserResponseModel(SubvaultUserUserDetails subvaultUser) - : base("subvaultUser") + public CollectionUserResponseModel(CollectionUserUserDetails collectionUser) + : base("collectionUser") { - if(subvaultUser == null) + if(collectionUser == null) { - throw new ArgumentNullException(nameof(subvaultUser)); + throw new ArgumentNullException(nameof(collectionUser)); } - Id = subvaultUser.Id?.ToString(); - OrganizationUserId = subvaultUser.OrganizationUserId.ToString(); - SubvaultId = subvaultUser.SubvaultId?.ToString(); - AccessAllSubvaults = subvaultUser.AccessAllSubvaults; - Name = subvaultUser.Name; - Email = subvaultUser.Email; - Type = subvaultUser.Type; - Status = subvaultUser.Status; - ReadOnly = subvaultUser.ReadOnly; + Id = collectionUser.Id?.ToString(); + OrganizationUserId = collectionUser.OrganizationUserId.ToString(); + CollectionId = collectionUser.CollectionId?.ToString(); + AccessAllCollections = collectionUser.AccessAllCollections; + Name = collectionUser.Name; + Email = collectionUser.Email; + Type = collectionUser.Type; + Status = collectionUser.Status; + ReadOnly = collectionUser.ReadOnly; } public string Id { get; set; } public string OrganizationUserId { get; set; } - public string SubvaultId { get; set; } - public bool AccessAllSubvaults { get; set; } + public string CollectionId { get; set; } + public bool AccessAllCollections { get; set; } public string Name { get; set; } public string Email { get; set; } public OrganizationUserType Type { get; set; } diff --git a/src/Core/Models/Data/OrganizationUserUserDetails.cs b/src/Core/Models/Data/OrganizationUserUserDetails.cs index 3f4c6b7840..92ca773c13 100644 --- a/src/Core/Models/Data/OrganizationUserUserDetails.cs +++ b/src/Core/Models/Data/OrganizationUserUserDetails.cs @@ -11,6 +11,6 @@ namespace Bit.Core.Models.Data public string Email { get; set; } public Enums.OrganizationUserStatusType Status { get; set; } public Enums.OrganizationUserType Type { get; set; } - public bool AccessAllSubvaults { get; set; } + public bool AccessAllCollections { get; set; } } } diff --git a/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs b/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs index 71b906a5a5..fd9f63f473 100644 --- a/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs +++ b/src/Core/Models/Data/SubvaultUserSubvaultDetails.cs @@ -2,12 +2,12 @@ namespace Bit.Core.Models.Data { - public class SubvaultUserSubvaultDetails + public class CollectionUserCollectionDetails { public Guid Id { get; set; } public Guid OrganizationUserId { get; set; } public string Name { get; set; } - public Guid SubvaultId { get; set; } + public Guid CollectionId { get; set; } public bool ReadOnly { get; set; } } } diff --git a/src/Core/Models/Data/SubvaultUserUserDetails.cs b/src/Core/Models/Data/SubvaultUserUserDetails.cs index 55b72518a3..cb5775f082 100644 --- a/src/Core/Models/Data/SubvaultUserUserDetails.cs +++ b/src/Core/Models/Data/SubvaultUserUserDetails.cs @@ -2,12 +2,12 @@ namespace Bit.Core.Models.Data { - public class SubvaultUserUserDetails + public class CollectionUserUserDetails { public Guid? Id { get; set; } public Guid OrganizationUserId { get; set; } - public Guid? SubvaultId { get; set; } - public bool AccessAllSubvaults { get; set; } + public Guid? CollectionId { get; set; } + public bool AccessAllCollections { get; set; } public string Name { get; set; } public string Email { get; set; } public Enums.OrganizationUserStatusType Status { get; set; } diff --git a/src/Core/Models/StaticStore/Plan.cs b/src/Core/Models/StaticStore/Plan.cs index 1b81e09dc5..d8f9a991a8 100644 --- a/src/Core/Models/StaticStore/Plan.cs +++ b/src/Core/Models/StaticStore/Plan.cs @@ -13,7 +13,7 @@ namespace Bit.Core.Models.StaticStore public short? MaxAdditionalSeats { get; set; } public decimal BasePrice { get; set; } public decimal SeatPrice { get; set; } - public short? MaxSubvaults { get; set; } + public short? MaxCollections { get; set; } public int UpgradeSortOrder { get; set; } public bool Disabled { get; set; } public int? TrialPeriodDays { get; set; } diff --git a/src/Core/Models/Table/Organization.cs b/src/Core/Models/Table/Organization.cs index ecba2faf81..64fdf9ee37 100644 --- a/src/Core/Models/Table/Organization.cs +++ b/src/Core/Models/Table/Organization.cs @@ -13,7 +13,7 @@ namespace Bit.Core.Models.Table public string Plan { get; set; } public PlanType PlanType { get; set; } public short? Seats { get; set; } - public short? MaxSubvaults { get; set; } + public short? MaxCollections { get; set; } public string StripeCustomerId { get; set; } public string StripeSubscriptionId { get; set; } public bool Enabled { get; set; } = true; diff --git a/src/Core/Models/Table/OrganizationUser.cs b/src/Core/Models/Table/OrganizationUser.cs index 30c74d480e..212858ff5c 100644 --- a/src/Core/Models/Table/OrganizationUser.cs +++ b/src/Core/Models/Table/OrganizationUser.cs @@ -13,7 +13,7 @@ namespace Bit.Core.Models.Table public string Key { get; set; } public OrganizationUserStatusType Status { get; set; } public OrganizationUserType Type { get; set; } - public bool AccessAllSubvaults { get; set; } + public bool AccessAllCollections { get; set; } public DateTime CreationDate { get; internal set; } = DateTime.UtcNow; public DateTime RevisionDate { get; internal set; } = DateTime.UtcNow; diff --git a/src/Core/Models/Table/Subvault.cs b/src/Core/Models/Table/Subvault.cs index 8f52016eeb..50aeaf2b28 100644 --- a/src/Core/Models/Table/Subvault.cs +++ b/src/Core/Models/Table/Subvault.cs @@ -3,7 +3,7 @@ using Bit.Core.Utilities; namespace Bit.Core.Models.Table { - public class Subvault : IDataObject + public class Collection : IDataObject { public Guid Id { get; set; } public Guid OrganizationId { get; set; } diff --git a/src/Core/Models/Table/SubvaultCipher.cs b/src/Core/Models/Table/SubvaultCipher.cs index ae87ab41fc..7109bdeac6 100644 --- a/src/Core/Models/Table/SubvaultCipher.cs +++ b/src/Core/Models/Table/SubvaultCipher.cs @@ -2,9 +2,9 @@ namespace Bit.Core.Models.Table { - public class SubvaultCipher + public class CollectionCipher { - public Guid SubvaultId { get; set; } + public Guid CollectionId { get; set; } public Guid CipherId { get; set; } } } diff --git a/src/Core/Models/Table/SubvaultUser.cs b/src/Core/Models/Table/SubvaultUser.cs index b6dba5c7bd..f559db0a12 100644 --- a/src/Core/Models/Table/SubvaultUser.cs +++ b/src/Core/Models/Table/SubvaultUser.cs @@ -3,10 +3,10 @@ using Bit.Core.Utilities; namespace Bit.Core.Models.Table { - public class SubvaultUser : IDataObject + public class CollectionUser : IDataObject { public Guid Id { get; set; } - public Guid SubvaultId { 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; diff --git a/src/Core/Repositories/ICipherRepository.cs b/src/Core/Repositories/ICipherRepository.cs index d6c3b3f7dc..bcf8c2c7a7 100644 --- a/src/Core/Repositories/ICipherRepository.cs +++ b/src/Core/Repositories/ICipherRepository.cs @@ -11,13 +11,13 @@ namespace Bit.Core.Repositories Task GetByIdAsync(Guid id, Guid userId); Task GetFullDetailsByIdAsync(Guid id, Guid userId); Task> GetManyByUserIdAsync(Guid userId); - Task> GetManyByUserIdHasSubvaultsAsync(Guid userId); + Task> GetManyByUserIdHasCollectionsAsync(Guid userId); Task> GetManyByOrganizationIdAsync(Guid organizationId); Task> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId); Task CreateAsync(CipherDetails cipher); Task ReplaceAsync(CipherDetails cipher); Task UpsertAsync(CipherDetails cipher); - Task ReplaceAsync(Cipher obj, IEnumerable subvaultIds); + Task ReplaceAsync(Cipher obj, IEnumerable collectionIds); Task UpdatePartialAsync(Guid id, Guid userId, Guid? folderId, bool favorite); Task UpdateUserEmailPasswordAndCiphersAsync(User user, IEnumerable ciphers, IEnumerable folders); Task CreateAsync(IEnumerable ciphers, IEnumerable folders); diff --git a/src/Core/Repositories/IOrganizationUserRepository.cs b/src/Core/Repositories/IOrganizationUserRepository.cs index c6943a5b56..46d4e3527f 100644 --- a/src/Core/Repositories/IOrganizationUserRepository.cs +++ b/src/Core/Repositories/IOrganizationUserRepository.cs @@ -15,7 +15,7 @@ namespace Bit.Core.Repositories Task> GetManyByOrganizationAsync(Guid organizationId, OrganizationUserType? type); Task GetByOrganizationAsync(Guid organizationId, string email); Task GetByOrganizationAsync(Guid organizationId, Guid userId); - Task>> GetDetailsByIdAsync(Guid id); + Task>> GetDetailsByIdAsync(Guid id); Task> GetManyDetailsByOrganizationAsync(Guid organizationId); Task> GetManyDetailsByUserAsync(Guid userId, OrganizationUserStatusType? status = null); diff --git a/src/Core/Repositories/ISubvaultCipherRepository.cs b/src/Core/Repositories/ISubvaultCipherRepository.cs index ec3f9826f4..53d6a940d0 100644 --- a/src/Core/Repositories/ISubvaultCipherRepository.cs +++ b/src/Core/Repositories/ISubvaultCipherRepository.cs @@ -5,12 +5,12 @@ using System.Collections.Generic; namespace Bit.Core.Repositories { - public interface ISubvaultCipherRepository + public interface ICollectionCipherRepository { - Task> GetManyByUserIdAsync(Guid userId); - Task> GetManyByOrganizationIdAsync(Guid organizationId); - Task> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId); - Task UpdateSubvaultsAsync(Guid cipherId, Guid userId, IEnumerable subvaultIds); - Task UpdateSubvaultsForAdminAsync(Guid cipherId, Guid organizationId, IEnumerable subvaultIds); + Task> GetManyByUserIdAsync(Guid userId); + Task> GetManyByOrganizationIdAsync(Guid organizationId); + Task> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId); + Task UpdateCollectionsAsync(Guid cipherId, Guid userId, IEnumerable collectionIds); + Task UpdateCollectionsForAdminAsync(Guid cipherId, Guid organizationId, IEnumerable collectionIds); } } diff --git a/src/Core/Repositories/ISubvaultRepository.cs b/src/Core/Repositories/ISubvaultRepository.cs index 1297c3b4db..2b110a6137 100644 --- a/src/Core/Repositories/ISubvaultRepository.cs +++ b/src/Core/Repositories/ISubvaultRepository.cs @@ -5,11 +5,11 @@ using System.Collections.Generic; namespace Bit.Core.Repositories { - public interface ISubvaultRepository : IRepository + public interface ICollectionRepository : IRepository { Task GetCountByOrganizationIdAsync(Guid organizationId); - Task> GetManyByOrganizationIdAsync(Guid organizationId); - Task> GetManyByUserIdAsync(Guid userId); + Task> GetManyByOrganizationIdAsync(Guid organizationId); + Task> GetManyByUserIdAsync(Guid userId); } } diff --git a/src/Core/Repositories/ISubvaultUserRepository.cs b/src/Core/Repositories/ISubvaultUserRepository.cs index 96bd2f7129..dc8186c865 100644 --- a/src/Core/Repositories/ISubvaultUserRepository.cs +++ b/src/Core/Repositories/ISubvaultUserRepository.cs @@ -6,11 +6,11 @@ using Bit.Core.Models.Data; namespace Bit.Core.Repositories { - public interface ISubvaultUserRepository : IRepository + public interface ICollectionUserRepository : IRepository { - Task> GetManyByOrganizationUserIdAsync(Guid orgUserId); - Task> GetManyDetailsByUserIdAsync(Guid userId); - Task> GetManyDetailsBySubvaultIdAsync(Guid subvaultId); + Task> GetManyByOrganizationUserIdAsync(Guid orgUserId); + Task> GetManyDetailsByUserIdAsync(Guid userId); + Task> GetManyDetailsByCollectionIdAsync(Guid collectionId); Task GetCanEditByUserIdCipherIdAsync(Guid userId, Guid cipherId); } } diff --git a/src/Core/Repositories/SqlServer/CipherRepository.cs b/src/Core/Repositories/SqlServer/CipherRepository.cs index 98f6ff0b51..c739ed58a3 100644 --- a/src/Core/Repositories/SqlServer/CipherRepository.cs +++ b/src/Core/Repositories/SqlServer/CipherRepository.cs @@ -62,12 +62,12 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyByUserIdHasSubvaultsAsync(Guid userId) + public async Task> GetManyByUserIdHasCollectionsAsync(Guid userId) { using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.QueryAsync( - $"[{Schema}].[CipherDetails_ReadByUserIdHasSubvault]", + $"[{Schema}].[CipherDetails_ReadByUserIdHasCollection]", new { UserId = userId }, commandType: CommandType.StoredProcedure); @@ -142,16 +142,16 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task ReplaceAsync(Cipher obj, IEnumerable subvaultIds) + public async Task ReplaceAsync(Cipher obj, IEnumerable collectionIds) { - var objWithSubvaults = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)); - objWithSubvaults.SubvaultIds = subvaultIds.ToGuidIdArrayTVP(); + var objWithCollections = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj)); + objWithCollections.CollectionIds = collectionIds.ToGuidIdArrayTVP(); using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.ExecuteAsync( - $"[{Schema}].[Cipher_UpdateWithSubvaults]", - objWithSubvaults, + $"[{Schema}].[Cipher_UpdateWithCollections]", + objWithCollections, commandType: CommandType.StoredProcedure); } } @@ -419,9 +419,9 @@ namespace Bit.Core.Repositories.SqlServer return foldersTable; } - public class CipherWithSubvaults : Cipher + public class CipherWithCollections : Cipher { - public DataTable SubvaultIds { get; set; } + public DataTable CollectionIds { get; set; } } } } diff --git a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs index b7b95c773b..f5e6cb1dc0 100644 --- a/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs +++ b/src/Core/Repositories/SqlServer/OrganizationUserRepository.cs @@ -100,7 +100,7 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task>> GetDetailsByIdAsync(Guid id) + public async Task>> GetDetailsByIdAsync(Guid id) { using(var connection = new SqlConnection(ConnectionString)) { @@ -110,8 +110,8 @@ namespace Bit.Core.Repositories.SqlServer commandType: CommandType.StoredProcedure); var user = (await results.ReadAsync()).SingleOrDefault(); - var subvaults = (await results.ReadAsync()).ToList(); - return new Tuple>(user, subvaults); + var collections = (await results.ReadAsync()).ToList(); + return new Tuple>(user, collections); } } diff --git a/src/Core/Repositories/SqlServer/SubvaultCipherRepository.cs b/src/Core/Repositories/SqlServer/SubvaultCipherRepository.cs index ecf02edd31..dc1411b01c 100644 --- a/src/Core/Repositories/SqlServer/SubvaultCipherRepository.cs +++ b/src/Core/Repositories/SqlServer/SubvaultCipherRepository.cs @@ -10,22 +10,22 @@ using Bit.Core.Utilities; namespace Bit.Core.Repositories.SqlServer { - public class SubvaultCipherRepository : BaseRepository, ISubvaultCipherRepository + public class CollectionCipherRepository : BaseRepository, ICollectionCipherRepository { - public SubvaultCipherRepository(GlobalSettings globalSettings) + public CollectionCipherRepository(GlobalSettings globalSettings) : this(globalSettings.SqlServer.ConnectionString) { } - public SubvaultCipherRepository(string connectionString) + public CollectionCipherRepository(string connectionString) : base(connectionString) { } - public async Task> GetManyByUserIdAsync(Guid userId) + public async Task> GetManyByUserIdAsync(Guid userId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - "[dbo].[SubvaultCipher_ReadByUserId]", + var results = await connection.QueryAsync( + "[dbo].[CollectionCipher_ReadByUserId]", new { UserId = userId }, commandType: CommandType.StoredProcedure); @@ -33,12 +33,12 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyByOrganizationIdAsync(Guid organizationId) + public async Task> GetManyByOrganizationIdAsync(Guid organizationId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - "[dbo].[SubvaultCipher_ReadByOrganizationId]", + var results = await connection.QueryAsync( + "[dbo].[CollectionCipher_ReadByOrganizationId]", new { OrganizationId = organizationId }, commandType: CommandType.StoredProcedure); @@ -46,12 +46,12 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId) + public async Task> GetManyByUserIdCipherIdAsync(Guid userId, Guid cipherId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - "[dbo].[SubvaultCipher_ReadByUserIdCipherId]", + var results = await connection.QueryAsync( + "[dbo].[CollectionCipher_ReadByUserIdCipherId]", new { UserId = userId, CipherId = cipherId }, commandType: CommandType.StoredProcedure); @@ -59,24 +59,24 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task UpdateSubvaultsAsync(Guid cipherId, Guid userId, IEnumerable subvaultIds) + public async Task UpdateCollectionsAsync(Guid cipherId, Guid userId, IEnumerable collectionIds) { using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.ExecuteAsync( - "[dbo].[SubvaultCipher_UpdateSubvaults]", - new { CipherId = cipherId, UserId = userId, SubvaultIds = subvaultIds.ToGuidIdArrayTVP() }, + "[dbo].[CollectionCipher_UpdateCollections]", + new { CipherId = cipherId, UserId = userId, CollectionIds = collectionIds.ToGuidIdArrayTVP() }, commandType: CommandType.StoredProcedure); } } - public async Task UpdateSubvaultsForAdminAsync(Guid cipherId, Guid organizationId, IEnumerable subvaultIds) + public async Task UpdateCollectionsForAdminAsync(Guid cipherId, Guid organizationId, IEnumerable collectionIds) { using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.ExecuteAsync( - "[dbo].[SubvaultCipher_UpdateSubvaultsAdmin]", - new { CipherId = cipherId, OrganizationId = organizationId, SubvaultIds = subvaultIds.ToGuidIdArrayTVP() }, + "[dbo].[CollectionCipher_UpdateCollectionsAdmin]", + new { CipherId = cipherId, OrganizationId = organizationId, CollectionIds = collectionIds.ToGuidIdArrayTVP() }, commandType: CommandType.StoredProcedure); } } diff --git a/src/Core/Repositories/SqlServer/SubvaultRepository.cs b/src/Core/Repositories/SqlServer/SubvaultRepository.cs index c265620bc0..12792b380c 100644 --- a/src/Core/Repositories/SqlServer/SubvaultRepository.cs +++ b/src/Core/Repositories/SqlServer/SubvaultRepository.cs @@ -9,13 +9,13 @@ using System.Linq; namespace Bit.Core.Repositories.SqlServer { - public class SubvaultRepository : Repository, ISubvaultRepository + public class CollectionRepository : Repository, ICollectionRepository { - public SubvaultRepository(GlobalSettings globalSettings) + public CollectionRepository(GlobalSettings globalSettings) : this(globalSettings.SqlServer.ConnectionString) { } - public SubvaultRepository(string connectionString) + public CollectionRepository(string connectionString) : base(connectionString) { } @@ -24,7 +24,7 @@ namespace Bit.Core.Repositories.SqlServer using(var connection = new SqlConnection(ConnectionString)) { var results = await connection.ExecuteScalarAsync( - "[dbo].[Subvault_ReadCountByOrganizationId]", + "[dbo].[Collection_ReadCountByOrganizationId]", new { OrganizationId = organizationId }, commandType: CommandType.StoredProcedure); @@ -32,11 +32,11 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyByOrganizationIdAsync(Guid organizationId) + public async Task> GetManyByOrganizationIdAsync(Guid organizationId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( + var results = await connection.QueryAsync( $"[{Schema}].[{Table}_ReadByOrganizationId]", new { OrganizationId = organizationId }, commandType: CommandType.StoredProcedure); @@ -45,11 +45,11 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyByUserIdAsync(Guid userId) + public async Task> GetManyByUserIdAsync(Guid userId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( + var results = await connection.QueryAsync( $"[{Schema}].[{Table}_ReadByUserId]", new { UserId = userId }, commandType: CommandType.StoredProcedure); diff --git a/src/Core/Repositories/SqlServer/SubvaultUserRepository.cs b/src/Core/Repositories/SqlServer/SubvaultUserRepository.cs index 143f589343..cdd5deabe2 100644 --- a/src/Core/Repositories/SqlServer/SubvaultUserRepository.cs +++ b/src/Core/Repositories/SqlServer/SubvaultUserRepository.cs @@ -10,21 +10,21 @@ using Bit.Core.Models.Data; namespace Bit.Core.Repositories.SqlServer { - public class SubvaultUserRepository : Repository, ISubvaultUserRepository + public class CollectionUserRepository : Repository, ICollectionUserRepository { - public SubvaultUserRepository(GlobalSettings globalSettings) + public CollectionUserRepository(GlobalSettings globalSettings) : this(globalSettings.SqlServer.ConnectionString) { } - public SubvaultUserRepository(string connectionString) + public CollectionUserRepository(string connectionString) : base(connectionString) { } - public async Task> GetManyByOrganizationUserIdAsync(Guid orgUserId) + public async Task> GetManyByOrganizationUserIdAsync(Guid orgUserId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( + var results = await connection.QueryAsync( $"[{Schema}].[{Table}_ReadByOrganizationUserId]", new { OrganizationUserId = orgUserId }, commandType: CommandType.StoredProcedure); @@ -33,12 +33,12 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyDetailsByUserIdAsync(Guid userId) + public async Task> GetManyDetailsByUserIdAsync(Guid userId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - $"[{Schema}].[SubvaultUserSubvaultDetails_ReadByUserId]", + var results = await connection.QueryAsync( + $"[{Schema}].[CollectionUserCollectionDetails_ReadByUserId]", new { UserId = userId }, commandType: CommandType.StoredProcedure); @@ -46,13 +46,13 @@ namespace Bit.Core.Repositories.SqlServer } } - public async Task> GetManyDetailsBySubvaultIdAsync(Guid subvaultId) + public async Task> GetManyDetailsByCollectionIdAsync(Guid collectionId) { using(var connection = new SqlConnection(ConnectionString)) { - var results = await connection.QueryAsync( - $"[{Schema}].[SubvaultUserUserDetails_ReadBySubvaultId]", - new { SubvaultId = subvaultId }, + var results = await connection.QueryAsync( + $"[{Schema}].[CollectionUserUserDetails_ReadByCollectionId]", + new { CollectionId = collectionId }, commandType: CommandType.StoredProcedure); return results.ToList(); @@ -64,7 +64,7 @@ namespace Bit.Core.Repositories.SqlServer using(var connection = new SqlConnection(ConnectionString)) { var result = await connection.QueryFirstOrDefaultAsync( - $"[{Schema}].[SubvaultUser_ReadCanEditByCipherIdUserId]", + $"[{Schema}].[CollectionUser_ReadCanEditByCipherIdUserId]", new { UserId = userId, CipherId = cipherId }, commandType: CommandType.StoredProcedure); diff --git a/src/Core/ServiceCollectionExtensions.cs b/src/Core/ServiceCollectionExtensions.cs index 4b67bbb23d..d351551e68 100644 --- a/src/Core/ServiceCollectionExtensions.cs +++ b/src/Core/ServiceCollectionExtensions.cs @@ -15,10 +15,10 @@ namespace Bit.Core services.AddSingleton(); services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(); - services.AddSingleton(); + services.AddSingleton(); } public static void AddBaseServices(this IServiceCollection services) @@ -27,7 +27,7 @@ namespace Bit.Core services.AddScoped(); services.AddScoped(); services.AddScoped(); - services.AddScoped(); + services.AddScoped(); } public static void AddDefaultServices(this IServiceCollection services) diff --git a/src/Core/Services/ICipherService.cs b/src/Core/Services/ICipherService.cs index 22b36a463d..e7a8aa43fd 100644 --- a/src/Core/Services/ICipherService.cs +++ b/src/Core/Services/ICipherService.cs @@ -12,8 +12,8 @@ namespace Bit.Core.Services Task DeleteAsync(Cipher cipher, Guid deletingUserId, bool orgAdmin = false); Task SaveFolderAsync(Folder folder); Task DeleteFolderAsync(Folder folder); - Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable subvaultIds, Guid userId); - Task SaveSubvaultsAsync(Cipher cipher, IEnumerable subvaultIds, Guid savingUserId, bool orgAdmin); + Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable collectionIds, Guid userId); + Task SaveCollectionsAsync(Cipher cipher, IEnumerable collectionIds, Guid savingUserId, bool orgAdmin); Task ImportCiphersAsync(List folders, List ciphers, IEnumerable> folderRelationships); } diff --git a/src/Core/Services/IOrganizationService.cs b/src/Core/Services/IOrganizationService.cs index fb3bec2859..2cb328df0f 100644 --- a/src/Core/Services/IOrganizationService.cs +++ b/src/Core/Services/IOrganizationService.cs @@ -21,11 +21,11 @@ namespace Bit.Core.Services Task EnableAsync(Guid organizationId); Task UpdateAsync(Organization organization, bool updateBilling = false); Task InviteUserAsync(Guid organizationId, Guid invitingUserId, string email, - Enums.OrganizationUserType type, bool accessAllSubvaults, IEnumerable subvaults); + Enums.OrganizationUserType type, bool accessAllCollections, IEnumerable collections); Task ResendInviteAsync(Guid organizationId, Guid invitingUserId, Guid organizationUserId); Task AcceptUserAsync(Guid organizationUserId, User user, string token); Task ConfirmUserAsync(Guid organizationId, Guid organizationUserId, string key, Guid confirmingUserId); - Task SaveUserAsync(OrganizationUser user, Guid savingUserId, IEnumerable subvaults); + Task SaveUserAsync(OrganizationUser user, Guid savingUserId, IEnumerable collections); Task DeleteUserAsync(Guid organizationId, Guid organizationUserId, Guid deletingUserId); Task DeleteUserAsync(Guid organizationId, Guid userId); } diff --git a/src/Core/Services/ISubvaultService.cs b/src/Core/Services/ISubvaultService.cs index 43cd839b75..655bf7dd57 100644 --- a/src/Core/Services/ISubvaultService.cs +++ b/src/Core/Services/ISubvaultService.cs @@ -3,8 +3,8 @@ using Bit.Core.Models.Table; namespace Bit.Core.Services { - public interface ISubvaultService + public interface ICollectionService { - Task SaveAsync(Subvault subvault); + Task SaveAsync(Collection collection); } } diff --git a/src/Core/Services/Implementations/CipherService.cs b/src/Core/Services/Implementations/CipherService.cs index 630320f847..08e97e5c01 100644 --- a/src/Core/Services/Implementations/CipherService.cs +++ b/src/Core/Services/Implementations/CipherService.cs @@ -16,8 +16,8 @@ namespace Bit.Core.Services private readonly IUserRepository _userRepository; private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; - private readonly ISubvaultUserRepository _subvaultUserRepository; - private readonly ISubvaultCipherRepository _subvaultCipherRepository; + private readonly ICollectionUserRepository _collectionUserRepository; + private readonly ICollectionCipherRepository _collectionCipherRepository; private readonly IPushService _pushService; public CipherService( @@ -26,8 +26,8 @@ namespace Bit.Core.Services IUserRepository userRepository, IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, - ISubvaultUserRepository subvaultUserRepository, - ISubvaultCipherRepository subvaultCipherRepository, + ICollectionUserRepository collectionUserRepository, + ICollectionCipherRepository collectionCipherRepository, IPushService pushService) { _cipherRepository = cipherRepository; @@ -35,8 +35,8 @@ namespace Bit.Core.Services _userRepository = userRepository; _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; - _subvaultUserRepository = subvaultUserRepository; - _subvaultCipherRepository = subvaultCipherRepository; + _collectionUserRepository = collectionUserRepository; + _collectionCipherRepository = collectionCipherRepository; _pushService = pushService; } @@ -105,7 +105,7 @@ namespace Bit.Core.Services await _pushService.PushSyncFolderDeleteAsync(folder); } - public async Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable subvaultIds, Guid sharingUserId) + public async Task ShareAsync(Cipher cipher, Guid organizationId, IEnumerable collectionIds, Guid sharingUserId) { if(cipher.Id == default(Guid)) { @@ -122,17 +122,17 @@ namespace Bit.Core.Services throw new NotFoundException(); } - // Sproc will not save this UserId on the cipher. It is used limit scope of the subvaultIds. + // Sproc will not save this UserId on the cipher. It is used limit scope of the collectionIds. cipher.UserId = sharingUserId; cipher.OrganizationId = organizationId; cipher.RevisionDate = DateTime.UtcNow; - await _cipherRepository.ReplaceAsync(cipher, subvaultIds); + await _cipherRepository.ReplaceAsync(cipher, collectionIds); // push await _pushService.PushSyncCipherUpdateAsync(cipher); } - public async Task SaveSubvaultsAsync(Cipher cipher, IEnumerable subvaultIds, Guid savingUserId, bool orgAdmin) + public async Task SaveCollectionsAsync(Cipher cipher, IEnumerable collectionIds, Guid savingUserId, bool orgAdmin) { if(cipher.Id == default(Guid)) { @@ -144,15 +144,15 @@ namespace Bit.Core.Services throw new BadRequestException("Cipher must belong to an organization."); } - // The sprocs will validate that all subvaults belong to this org/user and that they have proper write permissions. + // The sprocs will validate that all collections belong to this org/user and that they have proper write permissions. if(orgAdmin) { - await _subvaultCipherRepository.UpdateSubvaultsForAdminAsync(cipher.Id, cipher.OrganizationId.Value, - subvaultIds); + await _collectionCipherRepository.UpdateCollectionsForAdminAsync(cipher.Id, cipher.OrganizationId.Value, + collectionIds); } else { - await _subvaultCipherRepository.UpdateSubvaultsAsync(cipher.Id, savingUserId, subvaultIds); + await _collectionCipherRepository.UpdateCollectionsAsync(cipher.Id, savingUserId, collectionIds); } // push @@ -213,7 +213,7 @@ namespace Bit.Core.Services return true; } - return await _subvaultUserRepository.GetCanEditByUserIdCipherIdAsync(userId, cipher.Id); + return await _collectionUserRepository.GetCanEditByUserIdCipherIdAsync(userId, cipher.Id); } } } diff --git a/src/Core/Services/Implementations/OrganizationService.cs b/src/Core/Services/Implementations/OrganizationService.cs index 378beaad9c..069e5cba5b 100644 --- a/src/Core/Services/Implementations/OrganizationService.cs +++ b/src/Core/Services/Implementations/OrganizationService.cs @@ -18,8 +18,8 @@ namespace Bit.Core.Services { private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; - private readonly ISubvaultRepository _subvaultRepository; - private readonly ISubvaultUserRepository _subvaultUserRepository; + private readonly ICollectionRepository _collectionRepository; + private readonly ICollectionUserRepository _collectionUserRepository; private readonly IUserRepository _userRepository; private readonly IDataProtector _dataProtector; private readonly IMailService _mailService; @@ -28,8 +28,8 @@ namespace Bit.Core.Services public OrganizationService( IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, - ISubvaultRepository subvaultRepository, - ISubvaultUserRepository subvaultUserRepository, + ICollectionRepository collectionRepository, + ICollectionUserRepository collectionUserRepository, IUserRepository userRepository, IDataProtectionProvider dataProtectionProvider, IMailService mailService, @@ -37,8 +37,8 @@ namespace Bit.Core.Services { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; - _subvaultRepository = subvaultRepository; - _subvaultUserRepository = subvaultUserRepository; + _collectionRepository = collectionRepository; + _collectionUserRepository = collectionUserRepository; _userRepository = userRepository; _dataProtector = dataProtectionProvider.CreateProtector("OrganizationServiceDataProtector"); _mailService = mailService; @@ -269,15 +269,15 @@ namespace Bit.Core.Services } } - if(newPlan.MaxSubvaults.HasValue && - (!organization.MaxSubvaults.HasValue || organization.MaxSubvaults.Value > newPlan.MaxSubvaults.Value)) + if(newPlan.MaxCollections.HasValue && + (!organization.MaxCollections.HasValue || organization.MaxCollections.Value > newPlan.MaxCollections.Value)) { - var subvaultCount = await _subvaultRepository.GetCountByOrganizationIdAsync(organization.Id); - if(subvaultCount > newPlan.MaxSubvaults.Value) + var collectionCount = await _collectionRepository.GetCountByOrganizationIdAsync(organization.Id); + if(collectionCount > newPlan.MaxCollections.Value) { - throw new BadRequestException($"Your organization currently has {subvaultCount} subvaults. " + - $"Your new plan allows for a maximum of ({newPlan.MaxSubvaults.Value}) subvaults. " + - "Remove some subvaults."); + throw new BadRequestException($"Your organization currently has {collectionCount} collections. " + + $"Your new plan allows for a maximum of ({newPlan.MaxCollections.Value}) collections. " + + "Remove some collections."); } } @@ -551,7 +551,7 @@ namespace Bit.Core.Services BusinessName = signup.BusinessName, PlanType = plan.Type, Seats = (short)(plan.BaseSeats + signup.AdditionalSeats), - MaxSubvaults = plan.MaxSubvaults, + MaxCollections = plan.MaxCollections, Plan = plan.Name, StripeCustomerId = customer?.Id, StripeSubscriptionId = subscription?.Id, @@ -570,7 +570,7 @@ namespace Bit.Core.Services Key = signup.OwnerKey, Type = OrganizationUserType.Owner, Status = OrganizationUserStatusType.Confirmed, - AccessAllSubvaults = true, + AccessAllCollections = true, CreationDate = DateTime.UtcNow, RevisionDate = DateTime.UtcNow }; @@ -672,7 +672,7 @@ namespace Bit.Core.Services } public async Task InviteUserAsync(Guid organizationId, Guid invitingUserId, string email, - OrganizationUserType type, bool accessAllSubvaults, IEnumerable subvaults) + OrganizationUserType type, bool accessAllCollections, IEnumerable collections) { var organization = await _organizationRepository.GetByIdAsync(organizationId); if(organization == null) @@ -705,15 +705,15 @@ namespace Bit.Core.Services Key = null, Type = type, Status = OrganizationUserStatusType.Invited, - AccessAllSubvaults = accessAllSubvaults, + AccessAllCollections = accessAllCollections, CreationDate = DateTime.UtcNow, RevisionDate = DateTime.UtcNow }; await _organizationUserRepository.CreateAsync(orgUser); - if(!orgUser.AccessAllSubvaults && subvaults.Any()) + if(!orgUser.AccessAllCollections && collections.Any()) { - await SaveUserSubvaultsAsync(orgUser, subvaults, true); + await SaveUserCollectionsAsync(orgUser, collections, true); } await SendInviteAsync(orgUser); @@ -820,7 +820,7 @@ namespace Bit.Core.Services return orgUser; } - public async Task SaveUserAsync(OrganizationUser user, Guid savingUserId, IEnumerable subvaults) + public async Task SaveUserAsync(OrganizationUser user, Guid savingUserId, IEnumerable collections) { if(user.Id.Equals(default(Guid))) { @@ -835,12 +835,12 @@ namespace Bit.Core.Services await _organizationUserRepository.ReplaceAsync(user); - if(user.AccessAllSubvaults) + if(user.AccessAllCollections) { - // We don't need any subvaults if we're flagged to have all access. - subvaults = new List(); + // We don't need any collections if we're flagged to have all access. + collections = new List(); } - await SaveUserSubvaultsAsync(user, subvaults, false); + await SaveUserCollectionsAsync(user, collections, false); } public async Task DeleteUserAsync(Guid organizationId, Guid organizationUserId, Guid deletingUserId) @@ -889,38 +889,38 @@ namespace Bit.Core.Services return owners.Where(o => o.Status == Enums.OrganizationUserStatusType.Confirmed); } - private async Task SaveUserSubvaultsAsync(OrganizationUser user, IEnumerable subvaults, bool newUser) + private async Task SaveUserCollectionsAsync(OrganizationUser user, IEnumerable collections, bool newUser) { - if(subvaults == null) + if(collections == null) { - subvaults = new List(); + collections = new List(); } - var orgSubvaults = await _subvaultRepository.GetManyByOrganizationIdAsync(user.OrganizationId); - var currentUserSubvaults = newUser ? null : await _subvaultUserRepository.GetManyByOrganizationUserIdAsync(user.Id); + var orgCollections = await _collectionRepository.GetManyByOrganizationIdAsync(user.OrganizationId); + var currentUserCollections = newUser ? null : await _collectionUserRepository.GetManyByOrganizationUserIdAsync(user.Id); // Let's make sure all these belong to this user and organization. - var filteredSubvaults = subvaults.Where(s => orgSubvaults.Any(os => os.Id == s.SubvaultId)); - foreach(var subvault in filteredSubvaults) + var filteredCollections = collections.Where(s => orgCollections.Any(os => os.Id == s.CollectionId)); + foreach(var collection in filteredCollections) { - var existingSubvaultUser = currentUserSubvaults?.FirstOrDefault(cs => cs.SubvaultId == subvault.SubvaultId); - if(existingSubvaultUser != null) + var existingCollectionUser = currentUserCollections?.FirstOrDefault(cs => cs.CollectionId == collection.CollectionId); + if(existingCollectionUser != null) { - subvault.Id = existingSubvaultUser.Id; - subvault.CreationDate = existingSubvaultUser.CreationDate; + collection.Id = existingCollectionUser.Id; + collection.CreationDate = existingCollectionUser.CreationDate; } - subvault.OrganizationUserId = user.Id; - await _subvaultUserRepository.UpsertAsync(subvault); + collection.OrganizationUserId = user.Id; + await _collectionUserRepository.UpsertAsync(collection); } if(!newUser) { - var subvaultsToDelete = currentUserSubvaults.Where(cs => - !filteredSubvaults.Any(s => s.SubvaultId == cs.SubvaultId)); - foreach(var subvault in subvaultsToDelete) + var collectionsToDelete = currentUserCollections.Where(cs => + !filteredCollections.Any(s => s.CollectionId == cs.CollectionId)); + foreach(var collection in collectionsToDelete) { - await _subvaultUserRepository.DeleteAsync(subvault); + await _collectionUserRepository.DeleteAsync(collection); } } } diff --git a/src/Core/Services/Implementations/SubvaultService.cs b/src/Core/Services/Implementations/SubvaultService.cs index b03cbf2bd9..1077d8d42e 100644 --- a/src/Core/Services/Implementations/SubvaultService.cs +++ b/src/Core/Services/Implementations/SubvaultService.cs @@ -6,56 +6,56 @@ using Bit.Core.Repositories; namespace Bit.Core.Services { - public class SubvaultService : ISubvaultService + public class CollectionService : ICollectionService { private readonly IOrganizationRepository _organizationRepository; private readonly IOrganizationUserRepository _organizationUserRepository; - private readonly ISubvaultRepository _subvaultRepository; - private readonly ISubvaultUserRepository _subvaultUserRepository; + private readonly ICollectionRepository _collectionRepository; + private readonly ICollectionUserRepository _collectionUserRepository; private readonly IUserRepository _userRepository; private readonly IMailService _mailService; - public SubvaultService( + public CollectionService( IOrganizationRepository organizationRepository, IOrganizationUserRepository organizationUserRepository, - ISubvaultRepository subvaultRepository, - ISubvaultUserRepository subvaultUserRepository, + ICollectionRepository collectionRepository, + ICollectionUserRepository collectionUserRepository, IUserRepository userRepository, IMailService mailService) { _organizationRepository = organizationRepository; _organizationUserRepository = organizationUserRepository; - _subvaultRepository = subvaultRepository; - _subvaultUserRepository = subvaultUserRepository; + _collectionRepository = collectionRepository; + _collectionUserRepository = collectionUserRepository; _userRepository = userRepository; _mailService = mailService; } - public async Task SaveAsync(Subvault subvault) + public async Task SaveAsync(Collection collection) { - if(subvault.Id == default(Guid)) + if(collection.Id == default(Guid)) { - var org = await _organizationRepository.GetByIdAsync(subvault.OrganizationId); + var org = await _organizationRepository.GetByIdAsync(collection.OrganizationId); if(org == null) { throw new BadRequestException("Org not found"); } - if(org.MaxSubvaults.HasValue) + if(org.MaxCollections.HasValue) { - var subvaultCount = await _subvaultRepository.GetCountByOrganizationIdAsync(org.Id); - if(org.MaxSubvaults.Value <= subvaultCount) + var collectionCount = await _collectionRepository.GetCountByOrganizationIdAsync(org.Id); + if(org.MaxCollections.Value <= collectionCount) { - throw new BadRequestException("You have reached the maximum number of subvaults " + - $"({org.MaxSubvaults.Value}) for this organization."); + throw new BadRequestException("You have reached the maximum number of collections " + + $"({org.MaxCollections.Value}) for this organization."); } } - await _subvaultRepository.CreateAsync(subvault); + await _collectionRepository.CreateAsync(collection); } else { - await _subvaultRepository.ReplaceAsync(subvault); + await _collectionRepository.ReplaceAsync(collection); } } } diff --git a/src/Core/Utilities/StaticStore.cs b/src/Core/Utilities/StaticStore.cs index 82b0f6b24d..6d234dbfc2 100644 --- a/src/Core/Utilities/StaticStore.cs +++ b/src/Core/Utilities/StaticStore.cs @@ -96,7 +96,7 @@ namespace Bit.Core.Utilities Type = PlanType.Free, BaseSeats = 2, CanBuyAdditionalSeats = false, - MaxSubvaults = 2, + MaxCollections = 2, Name = "Free", UpgradeSortOrder = -1 // Always the lowest plan, cannot be upgraded to }, diff --git a/src/Sql/dbo/Functions/UserCanEditCipher.sql b/src/Sql/dbo/Functions/UserCanEditCipher.sql index fdcfdc7651..313833410d 100644 --- a/src/Sql/dbo/Functions/UserCanEditCipher.sql +++ b/src/Sql/dbo/Functions/UserCanEditCipher.sql @@ -5,7 +5,7 @@ BEGIN ;WITH [CTE] AS( SELECT - CASE WHEN OU.[AccessAllSubvaults] = 1 OR SU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit] + CASE WHEN OU.[AccessAllCollections] = 1 OR SU.[ReadOnly] = 0 THEN 1 ELSE 0 END [CanEdit] FROM [dbo].[Cipher] C INNER JOIN @@ -13,14 +13,14 @@ BEGIN INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.[Id] = @CipherId AND OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) SELECT @CanEdit = CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END diff --git a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByIdUserId.sql b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByIdUserId.sql index 98571e2443..450b9c2312 100644 --- a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByIdUserId.sql +++ b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByIdUserId.sql @@ -14,9 +14,9 @@ BEGIN LEFT JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.Id = @Id AND ( @@ -25,7 +25,7 @@ BEGIN C.[UserId] IS NULL AND OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) ) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByTypeUserId.sql b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByTypeUserId.sql index 631eb59988..2193f8b9cb 100644 --- a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByTypeUserId.sql +++ b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByTypeUserId.sql @@ -14,9 +14,9 @@ BEGIN LEFT JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.[Type] = @Type AND ( @@ -25,7 +25,7 @@ BEGIN C.[UserId] IS NULL AND OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) ) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserId.sql index d58988e76b..e6e9ebc9c2 100644 --- a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserId.sql @@ -13,15 +13,15 @@ BEGIN LEFT JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.[UserId] = @UserId OR ( C.[UserId] IS NULL AND OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserIdHasSubvault.sql b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserIdHasSubvault.sql index 4e2a86aee9..09186eeae1 100644 --- a/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserIdHasSubvault.sql +++ b/src/Sql/dbo/Stored Procedures/CipherDetails_ReadByUserIdHasSubvault.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserIdHasSubvault] +CREATE PROCEDURE [dbo].[CipherDetails_ReadByUserIdHasCollection] @UserId UNIQUEIDENTIFIER AS BEGIN @@ -13,11 +13,11 @@ BEGIN INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/CipherFullDetails_ReadByIdUserId.sql b/src/Sql/dbo/Stored Procedures/CipherFullDetails_ReadByIdUserId.sql index 043093a04c..11cdcfdea9 100644 --- a/src/Sql/dbo/Stored Procedures/CipherFullDetails_ReadByIdUserId.sql +++ b/src/Sql/dbo/Stored Procedures/CipherFullDetails_ReadByIdUserId.sql @@ -18,9 +18,9 @@ BEGIN LEFT JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.Id = @Id AND ( @@ -29,7 +29,7 @@ BEGIN C.[UserId] IS NULL AND OU.[Status] = 2 -- 2 = Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) ) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Cipher_UpdateWithSubvaults.sql b/src/Sql/dbo/Stored Procedures/Cipher_UpdateWithSubvaults.sql index 019f8c9a43..282a48ee59 100644 --- a/src/Sql/dbo/Stored Procedures/Cipher_UpdateWithSubvaults.sql +++ b/src/Sql/dbo/Stored Procedures/Cipher_UpdateWithSubvaults.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Cipher_UpdateWithSubvaults] +CREATE PROCEDURE [dbo].[Cipher_UpdateWithCollections] @Id UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER, @@ -8,7 +8,7 @@ @Folders NVARCHAR(MAX), @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7), - @SubvaultIds AS [dbo].[GuidIdArray] READONLY + @CollectionIds AS [dbo].[GuidIdArray] READONLY AS BEGIN SET NOCOUNT ON @@ -24,35 +24,35 @@ BEGIN WHERE [Id] = @Id - ;WITH [AvailableSubvaultsCTE] AS( + ;WITH [AvailableCollectionsCTE] AS( SELECT S.[Id] FROM - [dbo].[Subvault] S + [dbo].[Collection] S INNER JOIN [Organization] O ON O.[Id] = S.[OrganizationId] INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[SubvaultId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[CollectionId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] WHERE O.[Id] = @OrganizationId AND O.[Enabled] = 1 AND OU.[Status] = 2 -- Confirmed - AND (OU.[AccessAllSubvaults] = 1 OR SU.[ReadOnly] = 0) + AND (OU.[AccessAllCollections] = 1 OR SU.[ReadOnly] = 0) ) - INSERT INTO [dbo].[SubvaultCipher] + INSERT INTO [dbo].[CollectionCipher] ( - [SubvaultId], + [CollectionId], [CipherId] ) SELECT [Id], @Id FROM - @SubvaultIds + @CollectionIds WHERE - [Id] IN (SELECT [Id] FROM [AvailableSubvaultsCTE]) + [Id] IN (SELECT [Id] FROM [AvailableCollectionsCTE]) IF @OrganizationId IS NOT NULL BEGIN diff --git a/src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql b/src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql index b169e2ca5e..6a1729aed2 100644 --- a/src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/Folder_DeleteById.sql @@ -18,14 +18,14 @@ BEGIN LEFT JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllSubvaults] = 0 AND SC.[CipherId] = C.[Id] + [dbo].[CollectionCipher] SC ON C.[UserId] IS NULL AND OU.[AccessAllCollections] = 0 AND SC.[CipherId] = C.[Id] LEFT JOIN - [dbo].[SubvaultUser] SU ON SU.[SubvaultId] = SC.[SubvaultId] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON SU.[CollectionId] = SC.[CollectionId] AND SU.[OrganizationUserId] = OU.[Id] WHERE C.[UserId] = @UserId OR ( C.[UserId] IS NULL - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) ) AND C.[Folders] IS NOT NULL AND JSON_VALUE(C.[Folders], @UserIdPath) = @Id diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUserUserDetails_ReadById.sql b/src/Sql/dbo/Stored Procedures/OrganizationUserUserDetails_ReadById.sql index 8c11b19678..fe0ac62df2 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUserUserDetails_ReadById.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUserUserDetails_ReadById.sql @@ -14,7 +14,7 @@ BEGIN SELECT * FROM - [dbo].[SubvaultUserSubvaultDetailsView] + [dbo].[CollectionUserCollectionDetailsView] WHERE [OrganizationUserId] = @Id END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql b/src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql index 3f14003170..8ca5f27e8f 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUser_Create.sql @@ -6,7 +6,7 @@ @Key VARCHAR(MAX), @Status TINYINT, @Type TINYINT, - @AccessAllSubvaults BIT, + @AccessAllCollections BIT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) AS @@ -22,7 +22,7 @@ BEGIN [Key], [Status], [Type], - [AccessAllSubvaults], + [AccessAllCollections], [CreationDate], [RevisionDate] ) @@ -35,7 +35,7 @@ BEGIN @Key, @Status, @Type, - @AccessAllSubvaults, + @AccessAllCollections, @CreationDate, @RevisionDate ) diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql b/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql index 60bc4e1a4d..c5d634f922 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUser_DeleteById.sql @@ -6,7 +6,7 @@ BEGIN DELETE FROM - [dbo].[SubvaultUser] + [dbo].[CollectionUser] WHERE [OrganizationUserId] = @Id diff --git a/src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql b/src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql index 997bfdc24c..5fa1479508 100644 --- a/src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql +++ b/src/Sql/dbo/Stored Procedures/OrganizationUser_Update.sql @@ -6,7 +6,7 @@ @Key VARCHAR(MAX), @Status TINYINT, @Type TINYINT, - @AccessAllSubvaults BIT, + @AccessAllCollections BIT, @CreationDate DATETIME2(7), @RevisionDate DATETIME2(7) AS @@ -22,7 +22,7 @@ BEGIN [Key] = @Key, [Status] = @Status, [Type] = @Type, - [AccessAllSubvaults] = @AccessAllSubvaults, + [AccessAllCollections] = @AccessAllCollections, [CreationDate] = @CreationDate, [RevisionDate] = @RevisionDate WHERE diff --git a/src/Sql/dbo/Stored Procedures/Organization_Create.sql b/src/Sql/dbo/Stored Procedures/Organization_Create.sql index 6e93749ec0..3a40e291a9 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Create.sql @@ -6,7 +6,7 @@ @Plan NVARCHAR(20), @PlanType TINYINT, @Seats SMALLINT, - @MaxSubvaults SMALLINT, + @MaxCollections SMALLINT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @Enabled BIT, @@ -25,7 +25,7 @@ BEGIN [Plan], [PlanType], [Seats], - [MaxSubvaults], + [MaxCollections], [StripeCustomerId], [StripeSubscriptionId], [Enabled], @@ -41,7 +41,7 @@ BEGIN @Plan, @PlanType, @Seats, - @MaxSubvaults, + @MaxCollections, @StripeCustomerId, @StripeSubscriptionId, @Enabled, diff --git a/src/Sql/dbo/Stored Procedures/Organization_Update.sql b/src/Sql/dbo/Stored Procedures/Organization_Update.sql index 76636c4d63..9ab30dae9c 100644 --- a/src/Sql/dbo/Stored Procedures/Organization_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Organization_Update.sql @@ -6,7 +6,7 @@ @Plan NVARCHAR(20), @PlanType TINYINT, @Seats SMALLINT, - @MaxSubvaults SMALLINT, + @MaxCollections SMALLINT, @StripeCustomerId VARCHAR(50), @StripeSubscriptionId VARCHAR(50), @Enabled BIT, @@ -26,7 +26,7 @@ BEGIN [Plan] = @Plan, [PlanType] = @PlanType, [Seats] = @Seats, - [MaxSubvaults] = @MaxSubvaults, + [MaxCollections] = @MaxCollections, [StripeCustomerId] = @StripeCustomerId, [StripeSubscriptionId] = @StripeSubscriptionId, [Enabled] = @Enabled, diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_Create.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_Create.sql index bf285acfe2..e6cee3ad80 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_Create.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_Create.sql @@ -1,18 +1,18 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_Create] - @SubvaultId UNIQUEIDENTIFIER, +CREATE PROCEDURE [dbo].[CollectionCipher_Create] + @CollectionId UNIQUEIDENTIFIER, @CipherId UNIQUEIDENTIFIER AS BEGIN SET NOCOUNT ON - INSERT INTO [dbo].[SubvaultCipher] + INSERT INTO [dbo].[CollectionCipher] ( - [SubvaultId], + [CollectionId], [CipherId] ) VALUES ( - @SubvaultId, + @CollectionId, @CipherId ) diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_Delete.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_Delete.sql index 4e1a3f958a..b2b6f75aeb 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_Delete.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_Delete.sql @@ -1,5 +1,5 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_Delete] - @SubvaultId UNIQUEIDENTIFIER, +CREATE PROCEDURE [dbo].[CollectionCipher_Delete] + @CollectionId UNIQUEIDENTIFIER, @CipherId UNIQUEIDENTIFIER AS BEGIN @@ -7,9 +7,9 @@ BEGIN DELETE FROM - [dbo].[SubvaultCipher] + [dbo].[CollectionCipher] WHERE - [SubvaultId] = @SubvaultId + [CollectionId] = @CollectionId AND [CipherId] = @CipherId DECLARE @OrganizationId UNIQUEIDENTIFIER = (SELECT TOP 1 [OrganizationId] FROM [dbo].[Cipher] WHERE [Id] = @CipherId) diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByOrganizationId.sql index 9fe445d0d3..d30ab8a25a 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByOrganizationId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByOrganizationId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_ReadByOrganizationId] +CREATE PROCEDURE [dbo].[CollectionCipher_ReadByOrganizationId] @OrganizationId UNIQUEIDENTIFIER AS BEGIN @@ -7,9 +7,9 @@ BEGIN SELECT SC.* FROM - [dbo].[SubvaultCipher] SC + [dbo].[CollectionCipher] SC INNER JOIN - [dbo].[Subvault] S ON S.[Id] = SC.[SubvaultId] + [dbo].[Collection] S ON S.[Id] = SC.[CollectionId] WHERE S.[OrganizationId] = @OrganizationId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserId.sql index bb30df996a..d147a8d2cf 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_ReadByUserId] +CREATE PROCEDURE [dbo].[CollectionCipher_ReadByUserId] @UserId UNIQUEIDENTIFIER AS BEGIN @@ -7,14 +7,14 @@ BEGIN SELECT SC.* FROM - [dbo].[SubvaultCipher] SC + [dbo].[CollectionCipher] SC INNER JOIN - [dbo].[Subvault] S ON S.[Id] = SC.[SubvaultId] + [dbo].[Collection] S ON S.[Id] = SC.[CollectionId] INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[SubvaultId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[CollectionId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] WHERE OU.[Status] = 2 -- Confirmed - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql index 1fffe951e7..80466d83cc 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_ReadByUserIdCipherId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_ReadByUserIdCipherId] +CREATE PROCEDURE [dbo].[CollectionCipher_ReadByUserIdCipherId] @UserId UNIQUEIDENTIFIER, @CipherId UNIQUEIDENTIFIER AS @@ -8,15 +8,15 @@ BEGIN SELECT SC.* FROM - [dbo].[SubvaultCipher] SC + [dbo].[CollectionCipher] SC INNER JOIN - [dbo].[Subvault] S ON S.[Id] = SC.[SubvaultId] + [dbo].[Collection] S ON S.[Id] = SC.[CollectionId] INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = S.[OrganizationId] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[SubvaultId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[CollectionId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] WHERE SC.[CipherId] = @CipherId AND OU.[Status] = 2 -- Confirmed - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaults.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaults.sql index 3e8487c542..3c3bbb1091 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaults.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaults.sql @@ -1,7 +1,7 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_UpdateSubvaults] +CREATE PROCEDURE [dbo].[CollectionCipher_UpdateCollections] @CipherId UNIQUEIDENTIFIER, @UserId UNIQUEIDENTIFIER, - @SubvaultIds AS [dbo].[GuidIdArray] READONLY + @CollectionIds AS [dbo].[GuidIdArray] READONLY AS BEGIN SET NOCOUNT ON @@ -15,32 +15,32 @@ BEGIN [Id] = @CipherId ) - ;WITH [AvailableSubvaultsCTE] AS( + ;WITH [AvailableCollectionsCTE] AS( SELECT S.[Id] FROM - [dbo].[Subvault] S + [dbo].[Collection] S INNER JOIN [Organization] O ON O.[Id] = S.[OrganizationId] INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[SubvaultId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[CollectionId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] WHERE O.[Id] = @OrgId AND O.[Enabled] = 1 AND OU.[Status] = 2 -- Confirmed - AND (OU.[AccessAllSubvaults] = 1 OR SU.[ReadOnly] = 0) + AND (OU.[AccessAllCollections] = 1 OR SU.[ReadOnly] = 0) ) MERGE - [dbo].[SubvaultCipher] AS [Target] + [dbo].[CollectionCipher] AS [Target] USING - @SubvaultIds AS [Source] + @CollectionIds AS [Source] ON - [Target].[SubvaultId] = [Source].[Id] + [Target].[CollectionId] = [Source].[Id] AND [Target].[CipherId] = @CipherId WHEN NOT MATCHED BY TARGET - AND [Source].[Id] IN (SELECT [Id] FROM [AvailableSubvaultsCTE]) THEN + AND [Source].[Id] IN (SELECT [Id] FROM [AvailableCollectionsCTE]) THEN INSERT VALUES ( [Source].[Id], @@ -48,7 +48,7 @@ BEGIN ) WHEN NOT MATCHED BY SOURCE AND [Target].[CipherId] = @CipherId - AND [Target].[SubvaultId] IN (SELECT [Id] FROM [AvailableSubvaultsCTE]) THEN + AND [Target].[CollectionId] IN (SELECT [Id] FROM [AvailableCollectionsCTE]) THEN DELETE ; diff --git a/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaultsAdmin.sql b/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaultsAdmin.sql index dde179ad56..b8d71db180 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaultsAdmin.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultCipher_UpdateSubvaultsAdmin.sql @@ -1,28 +1,28 @@ -CREATE PROCEDURE [dbo].[SubvaultCipher_UpdateSubvaultsAdmin] +CREATE PROCEDURE [dbo].[CollectionCipher_UpdateCollectionsAdmin] @CipherId UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER, - @SubvaultIds AS [dbo].[GuidIdArray] READONLY + @CollectionIds AS [dbo].[GuidIdArray] READONLY AS BEGIN SET NOCOUNT ON - ;WITH [AvailableSubvaultsCTE] AS( + ;WITH [AvailableCollectionsCTE] AS( SELECT Id FROM - [dbo].[Subvault] + [dbo].[Collection] WHERE OrganizationId = @OrganizationId ) MERGE - [dbo].[SubvaultCipher] AS [Target] + [dbo].[CollectionCipher] AS [Target] USING - @SubvaultIds AS [Source] + @CollectionIds AS [Source] ON - [Target].[SubvaultId] = [Source].[Id] + [Target].[CollectionId] = [Source].[Id] AND [Target].[CipherId] = @CipherId WHEN NOT MATCHED BY TARGET - AND [Source].[Id] IN (SELECT [Id] FROM [AvailableSubvaultsCTE]) THEN + AND [Source].[Id] IN (SELECT [Id] FROM [AvailableCollectionsCTE]) THEN INSERT VALUES ( [Source].[Id], diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUserSubvaultDetails_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/SubvaultUserSubvaultDetails_ReadByUserId.sql index 391897d84e..bfcecefb11 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUserSubvaultDetails_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUserSubvaultDetails_ReadByUserId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultUserSubvaultDetails_ReadByUserId] +CREATE PROCEDURE [dbo].[CollectionUserCollectionDetails_ReadByUserId] @UserId UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT SU.* FROM - [dbo].[SubvaultUserSubvaultDetailsView] SU + [dbo].[CollectionUserCollectionDetailsView] SU INNER JOIN [OrganizationUser] OU ON SU.[OrganizationUserId] = OU.[Id] WHERE diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUserUserDetails_ReadBySubvaultId.sql b/src/Sql/dbo/Stored Procedures/SubvaultUserUserDetails_ReadBySubvaultId.sql index 5e84a8cb36..be31528ea7 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUserUserDetails_ReadBySubvaultId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUserUserDetails_ReadBySubvaultId.sql @@ -1,5 +1,5 @@ -CREATE PROCEDURE [dbo].[SubvaultUserUserDetails_ReadBySubvaultId] - @SubvaultId UNIQUEIDENTIFIER +CREATE PROCEDURE [dbo].[CollectionUserUserDetails_ReadByCollectionId] + @CollectionId UNIQUEIDENTIFIER AS BEGIN SET NOCOUNT ON @@ -7,8 +7,8 @@ BEGIN SELECT * FROM - [dbo].[SubvaultUserUserDetailsView] + [dbo].[CollectionUserUserDetailsView] WHERE - [AccessAllSubvaults] = 1 - OR [SubvaultId] = @SubvaultId + [AccessAllCollections] = 1 + OR [CollectionId] = @CollectionId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql index 516188e5e1..56e81b2f4b 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_Create.sql @@ -1,6 +1,6 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_Create] +CREATE PROCEDURE [dbo].[CollectionUser_Create] @Id UNIQUEIDENTIFIER, - @SubvaultId UNIQUEIDENTIFIER, + @CollectionId UNIQUEIDENTIFIER, @OrganizationUserId UNIQUEIDENTIFIER, @ReadOnly BIT, @CreationDate DATETIME2(7), @@ -9,10 +9,10 @@ AS BEGIN SET NOCOUNT ON - INSERT INTO [dbo].[SubvaultUser] + INSERT INTO [dbo].[CollectionUser] ( [Id], - [SubvaultId], + [CollectionId], [OrganizationUserId], [ReadOnly], [CreationDate], @@ -21,7 +21,7 @@ BEGIN VALUES ( @Id, - @SubvaultId, + @CollectionId, @OrganizationUserId, @ReadOnly, @CreationDate, diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_DeleteById.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_DeleteById.sql index e990920ec6..386248b192 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_DeleteById.sql @@ -1,14 +1,14 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_DeleteById] +CREATE PROCEDURE [dbo].[CollectionUser_DeleteById] @Id UNIQUEIDENTIFIER AS BEGIN SET NOCOUNT ON - DECLARE @OrganizationUserId UNIQUEIDENTIFIER = (SELECT TOP 1 [OrganizationUserId] FROM [dbo].[SubvaultUser] WHERE [Id] = @Id) + DECLARE @OrganizationUserId UNIQUEIDENTIFIER = (SELECT TOP 1 [OrganizationUserId] FROM [dbo].[CollectionUser] WHERE [Id] = @Id) DELETE FROM - [dbo].[SubvaultUser] + [dbo].[CollectionUser] WHERE [Id] = @Id diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadById.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadById.sql index 4059db7546..da31978806 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadById.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadById.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_ReadById] +CREATE PROCEDURE [dbo].[CollectionUser_ReadById] @Id UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT * FROM - [dbo].[SubvaultUserView] + [dbo].[CollectionUserView] WHERE [Id] = @Id END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadByOrganizationUserId.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadByOrganizationUserId.sql index 149c5a7149..531555bc8c 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadByOrganizationUserId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadByOrganizationUserId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_ReadByOrganizationUserId] +CREATE PROCEDURE [dbo].[CollectionUser_ReadByOrganizationUserId] @OrganizationUserId UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT * FROM - [dbo].[SubvaultUserView] + [dbo].[CollectionUserView] WHERE [OrganizationUserId] = @OrganizationUserId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadCanEditByCipherIdUserId.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadCanEditByCipherIdUserId.sql index 7143d13ce1..86c825fd2a 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadCanEditByCipherIdUserId.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_ReadCanEditByCipherIdUserId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_ReadCanEditByCipherIdUserId] +CREATE PROCEDURE [dbo].[CollectionUser_ReadCanEditByCipherIdUserId] @UserId UNIQUEIDENTIFIER, @CipherId AS UNIQUEIDENTIFIER AS diff --git a/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql b/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql index 813949581f..3f2c80f44c 100644 --- a/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql +++ b/src/Sql/dbo/Stored Procedures/SubvaultUser_Update.sql @@ -1,6 +1,6 @@ -CREATE PROCEDURE [dbo].[SubvaultUser_Update] +CREATE PROCEDURE [dbo].[CollectionUser_Update] @Id UNIQUEIDENTIFIER, - @SubvaultId UNIQUEIDENTIFIER, + @CollectionId UNIQUEIDENTIFIER, @OrganizationUserId UNIQUEIDENTIFIER, @ReadOnly BIT, @CreationDate DATETIME2(7), @@ -10,9 +10,9 @@ BEGIN SET NOCOUNT ON UPDATE - [dbo].[SubvaultUser] + [dbo].[CollectionUser] SET - [SubvaultId] = @SubvaultId, + [CollectionId] = @CollectionId, [OrganizationUserId] = @OrganizationUserId, [ReadOnly] = @ReadOnly, [CreationDate] = @CreationDate, diff --git a/src/Sql/dbo/Stored Procedures/Subvault_Create.sql b/src/Sql/dbo/Stored Procedures/Subvault_Create.sql index f3f0bce776..7e281184e6 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_Create.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_Create.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_Create] +CREATE PROCEDURE [dbo].[Collection_Create] @Id UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @@ -8,7 +8,7 @@ AS BEGIN SET NOCOUNT ON - INSERT INTO [dbo].[Subvault] + INSERT INTO [dbo].[Collection] ( [Id], [OrganizationId], diff --git a/src/Sql/dbo/Stored Procedures/Subvault_DeleteById.sql b/src/Sql/dbo/Stored Procedures/Subvault_DeleteById.sql index 3baedf2456..50643998ed 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_DeleteById.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_DeleteById.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_DeleteById] +CREATE PROCEDURE [dbo].[Collection_DeleteById] @Id UNIQUEIDENTIFIER AS BEGIN @@ -6,7 +6,7 @@ BEGIN DELETE FROM - [dbo].[Subvault] + [dbo].[Collection] WHERE [Id] = @Id END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Subvault_ReadById.sql b/src/Sql/dbo/Stored Procedures/Subvault_ReadById.sql index 8eadf56d41..e862a80196 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_ReadById.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_ReadById.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_ReadById] +CREATE PROCEDURE [dbo].[Collection_ReadById] @Id UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT * FROM - [dbo].[SubvaultView] + [dbo].[CollectionView] WHERE [Id] = @Id END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Subvault_ReadByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/Subvault_ReadByOrganizationId.sql index 0d827052cd..52c0cddaa5 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_ReadByOrganizationId.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_ReadByOrganizationId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_ReadByOrganizationId] +CREATE PROCEDURE [dbo].[Collection_ReadByOrganizationId] @OrganizationId UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT S.* FROM - [dbo].[SubvaultView] S + [dbo].[CollectionView] S WHERE S.[OrganizationId] = @OrganizationId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Subvault_ReadByUserId.sql b/src/Sql/dbo/Stored Procedures/Subvault_ReadByUserId.sql index 64532c4042..b95c8de873 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_ReadByUserId.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_ReadByUserId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_ReadByUserId] +CREATE PROCEDURE [dbo].[Collection_ReadByUserId] @UserId UNIQUEIDENTIFIER AS BEGIN @@ -7,15 +7,15 @@ BEGIN SELECT S.* FROM - [dbo].[SubvaultView] S + [dbo].[CollectionView] S INNER JOIN [Organization] O ON O.[Id] = S.[OrganizationId] INNER JOIN [dbo].[OrganizationUser] OU ON OU.[OrganizationId] = O.[Id] AND OU.[UserId] = @UserId LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[SubvaultId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[CollectionId] = S.[Id] AND SU.[OrganizationUserId] = OU.[Id] WHERE OU.[Status] = 2 -- Confirmed AND O.[Enabled] = 1 - AND (OU.[AccessAllSubvaults] = 1 OR SU.[SubvaultId] IS NOT NULL) + AND (OU.[AccessAllCollections] = 1 OR SU.[CollectionId] IS NOT NULL) END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Subvault_ReadCountByOrganizationId.sql b/src/Sql/dbo/Stored Procedures/Subvault_ReadCountByOrganizationId.sql index 2e60048a6b..9d4f03321c 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_ReadCountByOrganizationId.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_ReadCountByOrganizationId.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_ReadCountByOrganizationId] +CREATE PROCEDURE [dbo].[Collection_ReadCountByOrganizationId] @OrganizationId UNIQUEIDENTIFIER AS BEGIN @@ -7,7 +7,7 @@ BEGIN SELECT COUNT(1) FROM - [dbo].[Subvault] + [dbo].[Collection] WHERE [OrganizationId] = @OrganizationId END \ No newline at end of file diff --git a/src/Sql/dbo/Stored Procedures/Subvault_Update.sql b/src/Sql/dbo/Stored Procedures/Subvault_Update.sql index ade66f527d..1ca0b74ea0 100644 --- a/src/Sql/dbo/Stored Procedures/Subvault_Update.sql +++ b/src/Sql/dbo/Stored Procedures/Subvault_Update.sql @@ -1,4 +1,4 @@ -CREATE PROCEDURE [dbo].[Subvault_Update] +CREATE PROCEDURE [dbo].[Collection_Update] @Id UNIQUEIDENTIFIER, @OrganizationId UNIQUEIDENTIFIER, @Name VARCHAR(MAX), @@ -9,7 +9,7 @@ BEGIN SET NOCOUNT ON UPDATE - [dbo].[Subvault] + [dbo].[Collection] SET [OrganizationId] = @OrganizationId, [Name] = @Name, diff --git a/src/Sql/dbo/Tables/Organization.sql b/src/Sql/dbo/Tables/Organization.sql index 6de8895711..9b7c1fa912 100644 --- a/src/Sql/dbo/Tables/Organization.sql +++ b/src/Sql/dbo/Tables/Organization.sql @@ -6,7 +6,7 @@ [Plan] NVARCHAR (20) NOT NULL, [PlanType] TINYINT NOT NULL, [Seats] SMALLINT NULL, - [MaxSubvaults] SMALLINT NULL, + [MaxCollections] SMALLINT NULL, [StripeCustomerId] VARCHAR (50) NULL, [StripeSubscriptionId] VARCHAR (50) NULL, [Enabled] BIT NOT NULL, diff --git a/src/Sql/dbo/Tables/OrganizationUser.sql b/src/Sql/dbo/Tables/OrganizationUser.sql index ed7c0ce2f4..ee26e4616b 100644 --- a/src/Sql/dbo/Tables/OrganizationUser.sql +++ b/src/Sql/dbo/Tables/OrganizationUser.sql @@ -6,7 +6,7 @@ [Key] VARCHAR (MAX) NULL, [Status] TINYINT NOT NULL, [Type] TINYINT NOT NULL, - [AccessAllSubvaults] BIT NOT NULL, + [AccessAllCollections] BIT NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, CONSTRAINT [PK_OrganizationUser] PRIMARY KEY CLUSTERED ([Id] ASC), diff --git a/src/Sql/dbo/Tables/Subvault.sql b/src/Sql/dbo/Tables/Subvault.sql index 5f332bae5c..01057c093d 100644 --- a/src/Sql/dbo/Tables/Subvault.sql +++ b/src/Sql/dbo/Tables/Subvault.sql @@ -1,10 +1,10 @@ -CREATE TABLE [dbo].[Subvault] ( +CREATE TABLE [dbo].[Collection] ( [Id] UNIQUEIDENTIFIER NOT NULL, [OrganizationId] UNIQUEIDENTIFIER NOT NULL, [Name] VARCHAR (MAX) NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, - CONSTRAINT [PK_Subvault] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_Subvault_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE + CONSTRAINT [PK_Collection] PRIMARY KEY CLUSTERED ([Id] ASC), + CONSTRAINT [FK_Collection_Organization] FOREIGN KEY ([OrganizationId]) REFERENCES [dbo].[Organization] ([Id]) ON DELETE CASCADE ); diff --git a/src/Sql/dbo/Tables/SubvaultCipher.sql b/src/Sql/dbo/Tables/SubvaultCipher.sql index 681397959d..906ffced63 100644 --- a/src/Sql/dbo/Tables/SubvaultCipher.sql +++ b/src/Sql/dbo/Tables/SubvaultCipher.sql @@ -1,13 +1,13 @@ -CREATE TABLE [dbo].[SubvaultCipher] ( - [SubvaultId] UNIQUEIDENTIFIER NOT NULL, +CREATE TABLE [dbo].[CollectionCipher] ( + [CollectionId] UNIQUEIDENTIFIER NOT NULL, [CipherId] UNIQUEIDENTIFIER NOT NULL, - CONSTRAINT [PK_SubvaultCipher] PRIMARY KEY CLUSTERED ([SubvaultId] ASC, [CipherId] ASC), - CONSTRAINT [FK_SubvaultCipher_Cipher] FOREIGN KEY ([CipherId]) REFERENCES [dbo].[Cipher] ([Id]) ON DELETE CASCADE, - CONSTRAINT [FK_SubvaultCipher_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) ON DELETE CASCADE + CONSTRAINT [PK_CollectionCipher] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [CipherId] ASC), + CONSTRAINT [FK_CollectionCipher_Cipher] FOREIGN KEY ([CipherId]) REFERENCES [dbo].[Cipher] ([Id]) ON DELETE CASCADE, + CONSTRAINT [FK_CollectionCipher_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]) ON DELETE CASCADE ); GO -CREATE NONCLUSTERED INDEX [IX_SubvaultCipher_CipherId] - ON [dbo].[SubvaultCipher]([CipherId] ASC); +CREATE NONCLUSTERED INDEX [IX_CollectionCipher_CipherId] + ON [dbo].[CollectionCipher]([CipherId] ASC); diff --git a/src/Sql/dbo/Tables/SubvaultGroup.sql b/src/Sql/dbo/Tables/SubvaultGroup.sql index 2c4f885a70..87b386f866 100644 --- a/src/Sql/dbo/Tables/SubvaultGroup.sql +++ b/src/Sql/dbo/Tables/SubvaultGroup.sql @@ -1,8 +1,8 @@ -CREATE TABLE [dbo].[SubvaultGroup] ( - [SubvaultId] UNIQUEIDENTIFIER NOT NULL, +CREATE TABLE [dbo].[CollectionGroup] ( + [CollectionId] UNIQUEIDENTIFIER NOT NULL, [GroupId] UNIQUEIDENTIFIER NOT NULL, - CONSTRAINT [PK_SubvaultGroup] PRIMARY KEY CLUSTERED ([SubvaultId] ASC, [GroupId] ASC), - CONSTRAINT [FK_SubvaultGroup_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE, - CONSTRAINT [FK_SubvaultGroup_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) + CONSTRAINT [PK_CollectionGroup] PRIMARY KEY CLUSTERED ([CollectionId] ASC, [GroupId] ASC), + CONSTRAINT [FK_CollectionGroup_Group] FOREIGN KEY ([GroupId]) REFERENCES [dbo].[Group] ([Id]) ON DELETE CASCADE, + CONSTRAINT [FK_CollectionGroup_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]) ); diff --git a/src/Sql/dbo/Tables/SubvaultUser.sql b/src/Sql/dbo/Tables/SubvaultUser.sql index 96bd523226..580c0a30ee 100644 --- a/src/Sql/dbo/Tables/SubvaultUser.sql +++ b/src/Sql/dbo/Tables/SubvaultUser.sql @@ -1,17 +1,17 @@ -CREATE TABLE [dbo].[SubvaultUser] ( +CREATE TABLE [dbo].[CollectionUser] ( [Id] UNIQUEIDENTIFIER NOT NULL, - [SubvaultId] UNIQUEIDENTIFIER NOT NULL, + [CollectionId] UNIQUEIDENTIFIER NOT NULL, [OrganizationUserId] UNIQUEIDENTIFIER NOT NULL, [ReadOnly] BIT NOT NULL, [CreationDate] DATETIME2 (7) NOT NULL, [RevisionDate] DATETIME2 (7) NOT NULL, - CONSTRAINT [PK_SubvaultUser] PRIMARY KEY CLUSTERED ([Id] ASC), - CONSTRAINT [FK_SubvaultUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id]), - CONSTRAINT [FK_SubvaultUser_Subvault] FOREIGN KEY ([SubvaultId]) REFERENCES [dbo].[Subvault] ([Id]) ON DELETE CASCADE + CONSTRAINT [PK_CollectionUser] PRIMARY KEY CLUSTERED ([Id] ASC), + CONSTRAINT [FK_CollectionUser_OrganizationUser] FOREIGN KEY ([OrganizationUserId]) REFERENCES [dbo].[OrganizationUser] ([Id]), + CONSTRAINT [FK_CollectionUser_Collection] FOREIGN KEY ([CollectionId]) REFERENCES [dbo].[Collection] ([Id]) ON DELETE CASCADE ); GO -CREATE NONCLUSTERED INDEX [IX_SubvaultUser_SubvaultId] - ON [dbo].[SubvaultUser]([SubvaultId] ASC); +CREATE NONCLUSTERED INDEX [IX_CollectionUser_CollectionId] + ON [dbo].[CollectionUser]([CollectionId] ASC); diff --git a/src/Sql/dbo/Views/OrganizationUserUserDetailsView.sql b/src/Sql/dbo/Views/OrganizationUserUserDetailsView.sql index a935032b61..161eea200c 100644 --- a/src/Sql/dbo/Views/OrganizationUserUserDetailsView.sql +++ b/src/Sql/dbo/Views/OrganizationUserUserDetailsView.sql @@ -8,7 +8,7 @@ SELECT ISNULL(U.[Email], OU.[Email]) Email, OU.[Status], OU.[Type], - OU.[AccessAllSubvaults] + OU.[AccessAllCollections] FROM [dbo].[OrganizationUser] OU LEFT JOIN diff --git a/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql b/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql index 88193f2e85..c9f2f35443 100644 --- a/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql +++ b/src/Sql/dbo/Views/SubvaultUserSubvaultDetailsView.sql @@ -1,12 +1,12 @@ -CREATE VIEW [dbo].[SubvaultUserSubvaultDetailsView] +CREATE VIEW [dbo].[CollectionUserCollectionDetailsView] AS SELECT SU.[Id], SU.[OrganizationUserId], S.[Name], - S.[Id] SubvaultId, + S.[Id] CollectionId, SU.[ReadOnly] FROM - [dbo].[SubvaultUser] SU + [dbo].[CollectionUser] SU INNER JOIN - [dbo].[Subvault] S ON S.[Id] = SU.[SubvaultId] \ No newline at end of file + [dbo].[Collection] S ON S.[Id] = SU.[CollectionId] diff --git a/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql b/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql index 27fe69ce21..52f327bb9d 100644 --- a/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql +++ b/src/Sql/dbo/Views/SubvaultUserUserDetailsView.sql @@ -1,18 +1,18 @@ -CREATE VIEW [dbo].[SubvaultUserUserDetailsView] +CREATE VIEW [dbo].[CollectionUserUserDetailsView] AS SELECT OU.[Id] AS [OrganizationUserId], - OU.[AccessAllSubvaults], + OU.[AccessAllCollections], SU.[Id], - SU.[SubvaultId], + SU.[CollectionId], U.[Name], ISNULL(U.[Email], OU.[Email]) Email, OU.[Status], OU.[Type], - CASE WHEN OU.[AccessAllSubvaults] = 0 AND SU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly] + CASE WHEN OU.[AccessAllCollections] = 0 AND SU.[ReadOnly] = 1 THEN 1 ELSE 0 END [ReadOnly] FROM [dbo].[OrganizationUser] OU LEFT JOIN - [dbo].[SubvaultUser] SU ON OU.[AccessAllSubvaults] = 0 AND SU.[OrganizationUserId] = OU.[Id] + [dbo].[CollectionUser] SU ON OU.[AccessAllCollections] = 0 AND SU.[OrganizationUserId] = OU.[Id] LEFT JOIN [dbo].[User] U ON U.[Id] = OU.[UserId] \ No newline at end of file diff --git a/src/Sql/dbo/Views/SubvaultUserView.sql b/src/Sql/dbo/Views/SubvaultUserView.sql index d7a116fd9e..860f4236eb 100644 --- a/src/Sql/dbo/Views/SubvaultUserView.sql +++ b/src/Sql/dbo/Views/SubvaultUserView.sql @@ -1,6 +1,6 @@ -CREATE VIEW [dbo].[SubvaultUserView] +CREATE VIEW [dbo].[CollectionUserView] AS SELECT * FROM - [dbo].[SubvaultUser] \ No newline at end of file + [dbo].[CollectionUser] diff --git a/src/Sql/dbo/Views/SubvaultView.sql b/src/Sql/dbo/Views/SubvaultView.sql index 130d77421e..d1094c8dfd 100644 --- a/src/Sql/dbo/Views/SubvaultView.sql +++ b/src/Sql/dbo/Views/SubvaultView.sql @@ -1,6 +1,6 @@ -CREATE VIEW [dbo].[SubvaultView] +CREATE VIEW [dbo].[CollectionView] AS SELECT * FROM - [dbo].[Subvault] \ No newline at end of file + [dbo].[Collection]