galaeth-draft/Galaeth.DAL/Repositories/RefreshTokenRepository.cs

32 lines
1 KiB
C#
Raw Normal View History

2024-11-17 10:31:01 +01:00
using Dapper;
using Galaeth.Core.Entities;
using Galaeth.Core.Infrastructure;
using Galaeth.Core.RepositoryInterfaces;
using Injectio.Attributes;
namespace Galaeth.DAL.Repositories;
/// <inheritdoc cref="Galaeth.Core.RepositoryInterfaces.IRefreshTokenRepository" />
[RegisterScoped]
public class RefreshTokenRepository : BaseRepository<RefreshToken, string>, IRefreshTokenRepository
{
/// <summary>
/// Initializes a new instance of the <see cref="RefreshTokenRepository"/> class.
/// </summary>
/// <param name="db">Instance of <see cref="IDbConnectionProvider"/>.</param>
public RefreshTokenRepository(IDbConnectionProvider db)
: base(db)
{
}
/// <inheritdoc cref="Galaeth.Core.RepositoryInterfaces.IRefreshTokenRepository" />
public async Task RevokeAllForUser(Guid userId)
{
await WithDatabaseAsync(async connection => await connection.ExecuteAsync(
$"DELETE FROM {Table} WHERE userId = @pUserId", new
{
pUserId = userId,
}));
}
}