mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-11 06:18:39 +00:00
login partially works
This commit is contained in:
parent
51b652f36d
commit
8aca781675
3 changed files with 16 additions and 8 deletions
|
@ -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<IActionResult> 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",
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -45,8 +45,6 @@ namespace ProjectLighthouse {
|
|||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
app.UseEndpoints(endpoints => {
|
||||
endpoints.MapControllers();
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue