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

Added device identifier, APIs for updating token by identifier, Device creation/update upon signin.

This commit is contained in:
Kyle Spearrin
2016-06-21 00:08:22 -04:00
parent 8a34692e7c
commit 37ec1de7a3
12 changed files with 109 additions and 6 deletions

View File

@ -8,6 +8,7 @@ namespace Bit.Core.Repositories
public interface IDeviceRepository : IRepository<Device, Guid>
{
Task<Device> GetByIdAsync(Guid id, Guid userId);
Task<Device> GetByIdentifierAsync(string identifier, Guid userId);
Task<ICollection<Device>> GetManyByUserIdAsync(Guid userId);
}
}

View File

@ -30,6 +30,23 @@ namespace Bit.Core.Repositories.SqlServer
return device;
}
public async Task<Device> GetByIdentifierAsync(string identifier, Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))
{
var results = await connection.QueryAsync<Device>(
$"[{Schema}].[{Table}_ReadByIdentifierUserId]",
new
{
UserId = userId,
Identifier = identifier
},
commandType: CommandType.StoredProcedure);
return results.FirstOrDefault();
}
}
public async Task<ICollection<Device>> GetManyByUserIdAsync(Guid userId)
{
using(var connection = new SqlConnection(ConnectionString))