mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-21 16:52:27 +00:00
40 lines
No EOL
1.1 KiB
C#
40 lines
No EOL
1.1 KiB
C#
#nullable enable
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using ProjectLighthouse.Types;
|
|
|
|
namespace ProjectLighthouse.Controllers {
|
|
[ApiController]
|
|
[Route("LITTLEBIGPLANETPS3_XML/login")]
|
|
[Produces("text/xml")]
|
|
public class LoginController : ControllerBase {
|
|
private readonly Database database;
|
|
|
|
public LoginController(Database database) {
|
|
this.database = database;
|
|
}
|
|
|
|
[HttpPost]
|
|
public async Task<IActionResult> Login() {
|
|
string body = await new StreamReader(Request.Body).ReadToEndAsync();
|
|
|
|
LoginData loginData;
|
|
try {
|
|
loginData = LoginData.CreateFromString(body);
|
|
}
|
|
catch {
|
|
return this.BadRequest();
|
|
}
|
|
|
|
Token? token = await database.AuthenticateUser(loginData);
|
|
|
|
if(token == null) return this.StatusCode(403, "");
|
|
|
|
return this.Ok(new LoginResult {
|
|
AuthTicket = "MM_AUTH=" + token.UserToken,
|
|
LbpEnvVer = ServerSettings.ServerName
|
|
}.Serialize());
|
|
}
|
|
}
|
|
} |