diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index b6fb596a..68112091 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -1,3 +1,5 @@ +#nullable enable +using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Primitives; using ProjectLighthouse.Types; @@ -9,12 +11,19 @@ namespace ProjectLighthouse.Controllers { public class LoginController : ControllerBase { [HttpGet] [HttpPost] - public IActionResult Post() { - if(!this.Request.Query.TryGetValue("titleID", out StringValues _)) { - this.BadRequest(); - } + public async Task Login() { + if(!this.Request.Query.TryGetValue("titleID", out StringValues _)) + return this.BadRequest(""); -// string titleId = titleValues[0]; + if(!this.Request.Cookies.TryGetValue("MM_AUTH", out string? mmAuth) || mmAuth == null) + return this.BadRequest(""); // TODO: send 403 + + await using Database database = new(); + + // ReSharper disable once InvertIf + if(!await database.IsUserAuthenticated(mmAuth)) { + if(!await database.AuthenticateUser(mmAuth)) return this.BadRequest(""); // TODO: send 403 + } return this.Ok(new LoginResult { AuthTicket = "d2c6bbec59162a1e786ed24ad95f2b73", diff --git a/ProjectLighthouse/Database.cs b/ProjectLighthouse/Database.cs index a78aadd2..1aca2991 100644 --- a/ProjectLighthouse/Database.cs +++ b/ProjectLighthouse/Database.cs @@ -25,7 +25,8 @@ namespace ProjectLighthouse { User user = new() { Username = username, LocationId = l.Id, - Biography = "No biography provided" + Biography = "No biography provided", + Pins = "" }; this.Users.Add(user); diff --git a/ProjectLighthouse/Startup.cs b/ProjectLighthouse/Startup.cs index 89f938aa..173c5caf 100644 --- a/ProjectLighthouse/Startup.cs +++ b/ProjectLighthouse/Startup.cs @@ -45,8 +45,6 @@ namespace ProjectLighthouse { app.UseRouting(); - app.UseAuthorization(); - app.UseEndpoints(endpoints => { endpoints.MapControllers(); });