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:
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
@ -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)
|
||||
{
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user