mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-06 06:45:18 -04:00
Progress Overhaul + Profile Page and a LOT more! (#4262)
Co-authored-by: Amelia <77553571+Fesaa@users.noreply.github.com> Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Entities;
|
||||
using API.Services.Store;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
|
||||
namespace API.Middleware;
|
||||
|
||||
/// <summary>
|
||||
/// If the user is authenticated, will update the <see cref="AppUser.LastActive"/> field.
|
||||
/// </summary>
|
||||
/// <remarks>This should be last in the stack of middlewares</remarks>
|
||||
/// <param name="next"></param>
|
||||
public class UpdateUserAsActiveMiddleware(RequestDelegate next)
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext context, IUserContext userContext, IUnitOfWork unitOfWork)
|
||||
{
|
||||
try
|
||||
{
|
||||
var userId = userContext.GetUserId();
|
||||
if (userId > 0)
|
||||
{
|
||||
await unitOfWork.UserRepository.UpdateUserAsActive(userId.Value);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
await next(context);
|
||||
return;
|
||||
}
|
||||
|
||||
await next(context);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user