rdt-client/server/RdtClient.Service/Middleware/AuthorizeMiddleware.cs
Roger Far 02c154f094 Fixed few layout issues with spinners.
Add a new Test Folder button in settings to test.
Add Docker images.
2020-12-12 14:10:05 -07:00

32 lines
No EOL
840 B
C#

using System;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace RdtClient.Service.Middleware
{
public class AuthorizeMiddleware
{
private readonly RequestDelegate _next;
public AuthorizeMiddleware(RequestDelegate next)
{
_next = next;
}
/// <summary>
/// Return a 403 instead of a 401, it's quirk that QBittorrent has.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public async Task Invoke(HttpContext context)
{
await _next(context);
if (context.Response.StatusCode == (Int32) HttpStatusCode.Unauthorized)
{
context.Response.StatusCode = (Int32) HttpStatusCode.Forbidden;
}
}
}
}