add login/logout events to change tracker

default guest profile to minimum permissions
This commit is contained in:
RaidMax
2021-06-30 21:13:25 -05:00
parent 0019ed8dde
commit 0256fc35d2
5 changed files with 65 additions and 2 deletions

View File

@ -119,6 +119,14 @@ namespace WebfrontCore.Controllers.API
var claimsIdentity = new ClaimsIdentity(claims, "login");
var claimsPrinciple = new ClaimsPrincipal(claimsIdentity);
await SignInAsync(claimsPrinciple);
Manager.AddEvent(new GameEvent()
{
Origin = privilegedClient,
Type = GameEvent.EventType.Login,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
});
return Ok();
}
@ -137,6 +145,17 @@ namespace WebfrontCore.Controllers.API
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<IActionResult> LogoutAsync()
{
if (Authorized)
{
Manager.AddEvent(new GameEvent()
{
Origin = Client,
Type = GameEvent.EventType.Logout,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
});
}
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return Ok();

View File

@ -4,6 +4,7 @@ using Microsoft.AspNetCore.Mvc;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using System;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
@ -50,6 +51,14 @@ namespace WebfrontCore.Controllers
var claimsIdentity = new ClaimsIdentity(claims, "login");
var claimsPrinciple = new ClaimsPrincipal(claimsIdentity);
await SignInAsync(claimsPrinciple);
Manager.AddEvent(new GameEvent()
{
Origin = privilegedClient,
Type = GameEvent.EventType.Login,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
});
return Ok();
}
@ -66,6 +75,17 @@ namespace WebfrontCore.Controllers
[HttpGet]
public async Task<IActionResult> LogoutAsync()
{
if (Authorized)
{
Manager.AddEvent(new GameEvent()
{
Origin = Client,
Type = GameEvent.EventType.Logout,
Owner = Manager.GetServers().First(),
Data = HttpContext.Connection.RemoteIpAddress.ToString()
});
}
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction("Index", "Home");
}