Kavita/API/Services/AuthKeyService.cs
Joe Milazzo dec65b9262
More Polish (#4336)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com>
2026-01-10 09:06:52 -08:00

25 lines
702 B
C#

using System;
using System.Linq;
using System.Threading.Tasks;
using API.Data;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
namespace API.Services;
public interface IAuthKeyService
{
Task UpdateLastAccessedAsync(string authKey);
}
public class AuthKeyService(DataContext context, ILogger<AuthKeyService> logger) : IAuthKeyService
{
public async Task UpdateLastAccessedAsync(string authKey)
{
logger.LogTrace("Updating last accessed Auth key: {AuthKey}", authKey);
await context.AppUserAuthKey
.Where(k => k.Key == authKey)
.ExecuteUpdateAsync(s => s.SetProperty(k => k.LastAccessedAtUtc, DateTime.UtcNow));
}
}