astral-api/Astral.DAL/Repositories/RefreshTokenRepository.cs

36 lines
1.2 KiB
C#
Raw Normal View History

2024-12-14 17:31:17 +01:00
// <copyright file="RefreshTokenRepository.cs" company="alveus.dev">
// Copyright (c) alveus.dev. All rights reserved. Licensed under the MIT License.
// </copyright>
using Astral.Core.Entities;
using Astral.Core.Infrastructure;
using Astral.Core.RepositoryInterfaces;
using Dapper;
using Injectio.Attributes;
namespace Astral.DAL.Repositories;
/// <inheritdoc cref="Astral.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="IRefreshTokenRepository" />
public async Task RevokeAllForUser(Guid userId)
{
await WithDatabaseAsync(async connection => await connection.ExecuteAsync(
$"DELETE FROM {Table} WHERE userId = @pUserId", new
{
pUserId = userId,
}));
}
}