excise entity framework from all remaining code
This commit is contained in:
parent
d6c3133d52
commit
ff92c5f335
62 changed files with 402 additions and 1339 deletions
|
|
@ -14,14 +14,14 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
using System.Net;
|
||||
using Catalogger.Backend.Database;
|
||||
using Catalogger.Backend.Database.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Catalogger.Backend.Database.Repositories;
|
||||
using NodaTime;
|
||||
|
||||
namespace Catalogger.Backend.Api.Middleware;
|
||||
|
||||
public class AuthenticationMiddleware(DatabaseContext db, IClock clock) : IMiddleware
|
||||
public class AuthenticationMiddleware(ApiTokenRepository tokenRepository, IClock clock)
|
||||
: IMiddleware
|
||||
{
|
||||
public async Task InvokeAsync(HttpContext ctx, RequestDelegate next)
|
||||
{
|
||||
|
|
@ -37,9 +37,7 @@ public class AuthenticationMiddleware(DatabaseContext db, IClock clock) : IMiddl
|
|||
|
||||
var token = ctx.Request.Headers.Authorization.ToString();
|
||||
|
||||
var apiToken = await db.ApiTokens.FirstOrDefaultAsync(t =>
|
||||
t.DashboardToken == token && t.ExpiresAt > clock.GetCurrentInstant()
|
||||
);
|
||||
var apiToken = await tokenRepository.GetAsync(token);
|
||||
if (apiToken == null)
|
||||
{
|
||||
if (requireAuth)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue