1
0
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:
Kyle Spearrin
2015-12-26 23:09:53 -05:00
parent 437b971003
commit 8d7178bc74
14 changed files with 246 additions and 29 deletions

View File

@ -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);
}
}
}

View File

@ -144,5 +144,4 @@ namespace Bit.Api.Controllers
}
}
}
}