ProjectLighthouse/ProjectLighthouse.Servers.GameServer/Controllers/Login/LogoutController.cs

39 lines
No EOL
1 KiB
C#

using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Extensions;
using LBPUnion.ProjectLighthouse.Servers.GameServer.Helpers;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Entities.Token;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
namespace LBPUnion.ProjectLighthouse.Servers.GameServer.Controllers.Login;
[ApiController]
[Authorize]
[Route("LITTLEBIGPLANETPS3_XML/goodbye")]
[Produces("text/xml")]
public class LogoutController : ControllerBase
{
private readonly DatabaseContext database;
public LogoutController(DatabaseContext database)
{
this.database = database;
}
[HttpPost]
public async Task<IActionResult> OnPost()
{
GameTokenEntity token = this.GetToken();
UserEntity? user = await this.database.UserFromGameToken(token);
if (user == null) return this.Forbid();
await LogoutHelper.Logout(token, user, database);
return this.Ok();
}
}