35 lines
1.2 KiB
C#
35 lines
1.2 KiB
C#
// <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,
|
|
}));
|
|
}
|
|
}
|