1
0
mirror of https://github.com/bitwarden/server.git synced 2025-07-17 15:40:59 -05:00

remove old share solution code

This commit is contained in:
Kyle Spearrin
2017-02-28 22:51:29 -05:00
parent 321183c570
commit acb1fc0be5
17 changed files with 19 additions and 365 deletions

View File

@ -2,20 +2,16 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core.Domains;
using Bit.Core.Models.Data;
namespace Bit.Core.Repositories
{
public interface ICipherRepository : IRepository<Cipher, Guid>
{
Task<Cipher> GetByIdAsync(Guid id, Guid userId);
Task<CipherShare> GetShareByIdAsync(Guid id, Guid userId);
Task<ICollection<Cipher>> GetManyByUserIdAsync(Guid userId);
Task<ICollection<CipherShare>> GetManyShareByUserIdAsync(Guid userId);
Task<ICollection<Cipher>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId);
Task<ICollection<CipherShare>> GetManyShareByTypeAndUserIdAsync(Enums.CipherType type, Guid userId);
Task<Tuple<ICollection<Cipher>, ICollection<Guid>>>
GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId);
Task<Tuple<ICollection<Cipher>, ICollection<Guid>>> GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(
DateTime sinceRevisionDate, Guid userId);
Task UpdateUserEmailPasswordAndCiphersAsync(User user, IEnumerable<Cipher> ciphers);
Task CreateAsync(IEnumerable<Cipher> ciphers);
}

View File

@ -1,13 +0,0 @@
using System;
using Bit.Core.Domains;
using System.Threading.Tasks;
using System.Collections.Generic;
namespace Bit.Core.Repositories
{
public interface IShareRepository : IRepository<Share, Guid>
{
Task<Share> GetByIdAsync(Guid id, Guid userId);
Task<ICollection<Share>> GetManyByCipherId(Guid id);
}
}

View File

@ -7,7 +7,6 @@ using DataTableProxy;
using Bit.Core.Domains;
using System.Data;
using Dapper;
using Bit.Core.Models.Data;
namespace Bit.Core.Repositories.SqlServer
{
@ -32,19 +31,6 @@ namespace Bit.Core.Repositories.SqlServer
return cipher;
}
public async Task<CipherShare> GetShareByIdAsync(Guid id, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CipherShare>(
$"[{Schema}].[CipherShare_ReadById]",
new { UserId = userId },
commandType: CommandType.StoredProcedure);
return results.FirstOrDefault(c => c.UserId == userId);
}
}
public async Task<ICollection<Cipher>> GetManyByUserIdAsync(Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
@ -58,19 +44,6 @@ namespace Bit.Core.Repositories.SqlServer
}
}
public async Task<ICollection<CipherShare>> GetManyShareByUserIdAsync(Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CipherShare>(
$"[{Schema}].[CipherShare_ReadByUserId]",
new { UserId = userId },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
public async Task<ICollection<Cipher>> GetManyByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
@ -88,23 +61,6 @@ namespace Bit.Core.Repositories.SqlServer
}
}
public async Task<ICollection<CipherShare>> GetManyShareByTypeAndUserIdAsync(Enums.CipherType type, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<CipherShare>(
$"[{Schema}].[CipherShare_ReadByTypeUserId]",
new
{
Type = type,
UserId = userId
},
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
public async Task<Tuple<ICollection<Cipher>, ICollection<Guid>>>
GetManySinceRevisionDateAndUserIdWithDeleteHistoryAsync(DateTime sinceRevisionDate, Guid userId)
{

View File

@ -1,46 +0,0 @@
using System;
using Bit.Core.Domains;
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Data.SqlClient;
using Dapper;
using System.Data;
using System.Linq;
namespace Bit.Core.Repositories.SqlServer
{
public class ShareRepository : Repository<Share, Guid>, IShareRepository
{
public ShareRepository(GlobalSettings globalSettings)
: this(globalSettings.SqlServer.ConnectionString)
{ }
public ShareRepository(string connectionString)
: base(connectionString)
{ }
public async Task<Share> GetByIdAsync(Guid id, Guid userId)
{
var share = await GetByIdAsync(id);
if(share == null || (share.UserId != userId && share.SharerUserId != userId))
{
return null;
}
return share;
}
public async Task<ICollection<Share>> GetManyByCipherId(Guid cipherId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<Share>(
$"[{Schema}].[Share_ReadByCipherId]",
new { CipherId = cipherId },
commandType: CommandType.StoredProcedure);
return results.ToList();
}
}
}
}