Dont hardcode user as "jvyden"

This commit is contained in:
jvyden 2021-10-14 01:26:00 -04:00
commit 59ba45036d
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
7 changed files with 37 additions and 14 deletions

View file

@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using ProjectLighthouse.Helpers;
using ProjectLighthouse.Types;
@ -60,5 +61,13 @@ namespace ProjectLighthouse {
if(token == null) return null;
return await Users.FirstOrDefaultAsync(u => u.UserId == token.UserId);
}
public async Task<User?> UserFromRequest(HttpRequest request) {
if(!request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) {
return null;
}
return await UserFromAuthToken(mmAuth);
}
}
}