mirror of
https://github.com/bitwarden/server.git
synced 2025-01-22 21:51:22 +01:00
remove deprecated code
This commit is contained in:
parent
498ddae8f8
commit
71eca0962a
@ -16,7 +16,6 @@ namespace Bit.Api.Controllers
|
||||
public class CiphersController : Controller
|
||||
{
|
||||
private readonly ICipherRepository _cipherRepository;
|
||||
private readonly IFolderRepository _folderRepository;
|
||||
private readonly ICollectionCipherRepository _collectionCipherRepository;
|
||||
private readonly ICipherService _cipherService;
|
||||
private readonly IUserService _userService;
|
||||
@ -24,14 +23,12 @@ namespace Bit.Api.Controllers
|
||||
|
||||
public CiphersController(
|
||||
ICipherRepository cipherRepository,
|
||||
IFolderRepository folderRepository,
|
||||
ICollectionCipherRepository collectionCipherRepository,
|
||||
ICipherService cipherService,
|
||||
IUserService userService,
|
||||
CurrentContext currentContext)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_folderRepository = folderRepository;
|
||||
_collectionCipherRepository = collectionCipherRepository;
|
||||
_cipherService = cipherService;
|
||||
_userService = userService;
|
||||
@ -68,26 +65,11 @@ namespace Bit.Api.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("")]
|
||||
public async Task<ListResponseModel<CipherResponseModel>> Get(bool includeFolders = true, bool includeShared = false)
|
||||
public async Task<ListResponseModel<CipherResponseModel>> Get()
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var ciphers = await _cipherRepository.GetManyByUserIdAsync(userId);
|
||||
|
||||
// For backwards compat, do not include shared ciphers. Can be removed in a future release.
|
||||
if(!includeShared)
|
||||
{
|
||||
ciphers = ciphers.Where(c => !c.OrganizationId.HasValue).ToList();
|
||||
}
|
||||
|
||||
var responses = ciphers.Select(c => new CipherResponseModel(c)).ToList();
|
||||
|
||||
// Folders are included for backwards compat. Can be removed in a future release.
|
||||
if(includeFolders)
|
||||
{
|
||||
var folders = await _folderRepository.GetManyByUserIdAsync(userId);
|
||||
responses.AddRange(folders.Select(f => new CipherResponseModel(f)));
|
||||
}
|
||||
|
||||
return new ListResponseModel<CipherResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -123,39 +105,13 @@ namespace Bit.Api.Controllers
|
||||
return new ListResponseModel<CipherMiniDetailsResponseModel>(responses);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[HttpGet("history")]
|
||||
public Task<CipherHistoryResponseModel> Get(DateTime since)
|
||||
{
|
||||
return Task.FromResult(new CipherHistoryResponseModel());
|
||||
}
|
||||
|
||||
[HttpPost("import")]
|
||||
public async Task PostImport([FromBody]ImportPasswordsRequestModel model)
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var folders = model.Folders.Select(f => f.ToFolder(userId)).ToList();
|
||||
var ciphers = model.Logins.Select(l => l.ToCipherDetails(userId)).ToList();
|
||||
|
||||
await _cipherService.ImportCiphersAsync(
|
||||
folders,
|
||||
ciphers,
|
||||
model.FolderRelationships);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
[HttpPut("{id}/favorite")]
|
||||
[HttpPost("{id}/favorite")]
|
||||
public async Task Favorite(string id)
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var cipher = await _cipherRepository.GetByIdAsync(new Guid(id), userId);
|
||||
if(cipher == null)
|
||||
{
|
||||
throw new NotFoundException();
|
||||
}
|
||||
|
||||
await _cipherRepository.UpdatePartialAsync(new Guid(id), userId, cipher.FolderId, !cipher.Favorite);
|
||||
await _cipherService.ImportCiphersAsync(folders, ciphers, model.FolderRelationships);
|
||||
}
|
||||
|
||||
[HttpPut("{id}/partial")]
|
||||
|
@ -8,9 +8,6 @@ using Bit.Core.Models.Api;
|
||||
using Bit.Core.Exceptions;
|
||||
using Bit.Core.Services;
|
||||
using Bit.Core;
|
||||
using System.Collections.Generic;
|
||||
using Core.Models.Data;
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Api.Controllers
|
||||
{
|
||||
@ -21,20 +18,17 @@ namespace Bit.Api.Controllers
|
||||
public class LoginsController : Controller
|
||||
{
|
||||
private readonly ICipherRepository _cipherRepository;
|
||||
private readonly IFolderRepository _folderRepository;
|
||||
private readonly ICipherService _cipherService;
|
||||
private readonly IUserService _userService;
|
||||
private readonly CurrentContext _currentContext;
|
||||
|
||||
public LoginsController(
|
||||
ICipherRepository cipherRepository,
|
||||
IFolderRepository folderRepository,
|
||||
ICipherService cipherService,
|
||||
IUserService userService,
|
||||
CurrentContext currentContext)
|
||||
{
|
||||
_cipherRepository = cipherRepository;
|
||||
_folderRepository = folderRepository;
|
||||
_cipherService = cipherService;
|
||||
_userService = userService;
|
||||
_currentContext = currentContext;
|
||||
@ -72,10 +66,8 @@ namespace Bit.Api.Controllers
|
||||
public async Task<ListResponseModel<LoginResponseModel>> Get(string[] expand = null)
|
||||
{
|
||||
var userId = _userService.GetProperUserId(User).Value;
|
||||
var logins = await _cipherRepository.GetManyByTypeAndUserIdAsync(Core.Enums.CipherType.Login,
|
||||
userId);
|
||||
var logins = await _cipherRepository.GetManyByTypeAndUserIdAsync(Core.Enums.CipherType.Login, userId);
|
||||
var responses = logins.Select(l => new LoginResponseModel(l)).ToList();
|
||||
await ExpandManyAsync(logins, responses, expand, userId);
|
||||
return new ListResponseModel<LoginResponseModel>(responses);
|
||||
}
|
||||
|
||||
@ -161,39 +153,5 @@ namespace Bit.Api.Controllers
|
||||
|
||||
await _cipherService.DeleteAsync(login, userId);
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
private async Task ExpandManyAsync(IEnumerable<CipherDetails> logins, ICollection<LoginResponseModel> responses,
|
||||
string[] expand, Guid userId)
|
||||
{
|
||||
if(expand == null || expand.Count() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(expand.Any(e => e.ToLower() == "folder"))
|
||||
{
|
||||
var folders = await _folderRepository.GetManyByUserIdAsync(userId);
|
||||
if(folders != null && folders.Count() > 0)
|
||||
{
|
||||
foreach(var response in responses)
|
||||
{
|
||||
var login = logins.SingleOrDefault(s => s.Id.ToString() == response.Id);
|
||||
if(login == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var folder = folders.SingleOrDefault(f => f.Id == login.FolderId);
|
||||
if(folder == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
response.Folder = new FolderResponseModel(folder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
using Bit.Core.Models.Table;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
public class FolderDataModel
|
||||
{
|
||||
public FolderDataModel(Folder folder)
|
||||
{
|
||||
Name = folder.Name;
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Bit.Core.Models.Api
|
||||
{
|
||||
[Obsolete]
|
||||
public class CipherHistoryResponseModel : ResponseModel
|
||||
{
|
||||
public CipherHistoryResponseModel()
|
||||
: base("cipherHistory")
|
||||
{ }
|
||||
|
||||
public IEnumerable<CipherResponseModel> Revised { get; set; } = new List<CipherResponseModel>();
|
||||
public IEnumerable<string> Deleted { get; set; } = new List<string>();
|
||||
}
|
||||
}
|
@ -31,21 +31,6 @@ namespace Bit.Core.Models.Api
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public CipherMiniResponseModel(Folder folder, string obj = "cipherMini")
|
||||
: base(obj)
|
||||
{
|
||||
if(folder == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(folder));
|
||||
}
|
||||
|
||||
Id = folder.Id.ToString();
|
||||
Type = Enums.CipherType.Folder;
|
||||
RevisionDate = folder.RevisionDate;
|
||||
Data = new FolderDataModel(folder);
|
||||
}
|
||||
|
||||
public string Id { get; set; }
|
||||
public string OrganizationId { get; set; }
|
||||
public Enums.CipherType Type { get; set; }
|
||||
@ -63,11 +48,6 @@ namespace Bit.Core.Models.Api
|
||||
Edit = cipher.Edit;
|
||||
}
|
||||
|
||||
[Obsolete]
|
||||
public CipherResponseModel(Folder folder, string obj = "cipher")
|
||||
: base(folder, obj)
|
||||
{ }
|
||||
|
||||
public string FolderId { get; set; }
|
||||
public bool Favorite { get; set; }
|
||||
public bool Edit { get; set; }
|
||||
|
@ -51,8 +51,5 @@ namespace Bit.Core.Models.Api
|
||||
public string Password { get; set; }
|
||||
public string Notes { get; set; }
|
||||
public DateTime RevisionDate { get; set; }
|
||||
|
||||
[Obsolete]
|
||||
public FolderResponseModel Folder { get; set; }
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user