login partially works

This commit is contained in:
jvyden 2021-10-12 16:44:42 -04:00
commit 8aca781675
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
3 changed files with 16 additions and 8 deletions

View file

@ -1,3 +1,5 @@
#nullable enable
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Primitives; using Microsoft.Extensions.Primitives;
using ProjectLighthouse.Types; using ProjectLighthouse.Types;
@ -9,12 +11,19 @@ namespace ProjectLighthouse.Controllers {
public class LoginController : ControllerBase { public class LoginController : ControllerBase {
[HttpGet] [HttpGet]
[HttpPost] [HttpPost]
public IActionResult Post() { public async Task<IActionResult> Login() {
if(!this.Request.Query.TryGetValue("titleID", out StringValues _)) { if(!this.Request.Query.TryGetValue("titleID", out StringValues _))
this.BadRequest(); 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 { return this.Ok(new LoginResult {
AuthTicket = "d2c6bbec59162a1e786ed24ad95f2b73", AuthTicket = "d2c6bbec59162a1e786ed24ad95f2b73",

View file

@ -25,7 +25,8 @@ namespace ProjectLighthouse {
User user = new() { User user = new() {
Username = username, Username = username,
LocationId = l.Id, LocationId = l.Id,
Biography = "No biography provided" Biography = "No biography provided",
Pins = ""
}; };
this.Users.Add(user); this.Users.Add(user);

View file

@ -45,8 +45,6 @@ namespace ProjectLighthouse {
app.UseRouting(); app.UseRouting();
app.UseAuthorization();
app.UseEndpoints(endpoints => { app.UseEndpoints(endpoints => {
endpoints.MapControllers(); endpoints.MapControllers();
}); });