mirror of
https://github.com/bitwarden/server.git
synced 2025-07-03 17:12:49 -05:00
Added cipher service with bulk import to account controller
This commit is contained in:
@ -11,6 +11,7 @@ using Bit.Core.Domains;
|
||||
using Bit.Core.Enums;
|
||||
using Bit.Core;
|
||||
using System.Security.Claims;
|
||||
using System.Linq;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
@ -19,16 +20,18 @@ namespace Bit.Api.Controllers
|
||||
public class AccountsController : Controller
|
||||
{
|
||||
private readonly IUserService _userService;
|
||||
private readonly ICipherService _cipherService;
|
||||
private readonly UserManager<User> _userManager;
|
||||
private readonly CurrentContext _currentContext;
|
||||
|
||||
public AccountsController(
|
||||
IDataProtectionProvider dataProtectionProvider,
|
||||
IUserService userService,
|
||||
ICipherService cipherService,
|
||||
UserManager<User> userManager,
|
||||
CurrentContext currentContext)
|
||||
{
|
||||
_userService = userService;
|
||||
_cipherService = cipherService;
|
||||
_userManager = userManager;
|
||||
_currentContext = currentContext;
|
||||
}
|
||||
@ -206,5 +209,14 @@ namespace Bit.Api.Controllers
|
||||
var response = new TwoFactorResponseModel(user);
|
||||
return response;
|
||||
}
|
||||
|
||||
[HttpPost("import")]
|
||||
public async Task PostImport([FromBody]ImportRequestModel model)
|
||||
{
|
||||
await _cipherService.ImportCiphersAsync(
|
||||
model.Folders.Select(f => f.ToFolder(User.GetUserId())).ToList(),
|
||||
model.Sites.Select(s => s.ToSite(User.GetUserId())).ToList(),
|
||||
model.SiteRelationships);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,5 +144,4 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user