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