mirror of
https://github.com/bitwarden/server.git
synced 2025-06-27 14:16:19 -05:00
Add validation in CollectionsController to prevent deletion of DefaultUserCollection type
* Implemented a check to return a BadRequestObjectResult if an attempt is made to delete a collection of type DefaultUserCollection.
This commit is contained in:
parent
bcb90f2913
commit
308e8f4d72
@ -2,6 +2,7 @@
|
|||||||
using Bit.Api.Models.Public.Request;
|
using Bit.Api.Models.Public.Request;
|
||||||
using Bit.Api.Models.Public.Response;
|
using Bit.Api.Models.Public.Response;
|
||||||
using Bit.Core.Context;
|
using Bit.Core.Context;
|
||||||
|
using Bit.Core.Enums;
|
||||||
using Bit.Core.OrganizationFeatures.OrganizationCollections.Interfaces;
|
using Bit.Core.OrganizationFeatures.OrganizationCollections.Interfaces;
|
||||||
using Bit.Core.Repositories;
|
using Bit.Core.Repositories;
|
||||||
using Bit.Core.Services;
|
using Bit.Core.Services;
|
||||||
@ -116,6 +117,12 @@ public class CollectionsController : Controller
|
|||||||
{
|
{
|
||||||
return new NotFoundResult();
|
return new NotFoundResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (collection.Type == CollectionType.DefaultUserCollection)
|
||||||
|
{
|
||||||
|
return new BadRequestObjectResult(new ErrorResponseModel("You cannot delete a collection with the type as DefaultUserCollection."));
|
||||||
|
}
|
||||||
|
|
||||||
await _collectionRepository.DeleteAsync(collection);
|
await _collectionRepository.DeleteAsync(collection);
|
||||||
return new OkResult();
|
return new OkResult();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user