add login/logout events to change tracker
default guest profile to minimum permissions
This commit is contained in:
parent
0019ed8dde
commit
0256fc35d2
@ -61,7 +61,7 @@ namespace SharedLibraryCore
|
||||
Client ??= new EFClient()
|
||||
{
|
||||
ClientId = -1,
|
||||
Level = EFClient.Permission.User,
|
||||
Level = EFClient.Permission.Banned,
|
||||
CurrentAlias = new EFAlias() { Name = "Webfront Guest" }
|
||||
};
|
||||
}
|
||||
|
@ -151,6 +151,14 @@ namespace SharedLibraryCore
|
||||
/// a client's permission was changed
|
||||
/// </summary>
|
||||
ChangePermission = 111,
|
||||
/// <summary>
|
||||
/// client logged in to webfront
|
||||
/// </summary>
|
||||
Login = 112,
|
||||
/// <summary>
|
||||
/// client logged out of webfront
|
||||
/// </summary>
|
||||
Logout = 113,
|
||||
|
||||
// events "generated" by IW4MAdmin
|
||||
/// <summary>
|
||||
|
@ -66,7 +66,23 @@ namespace SharedLibraryCore.Services
|
||||
CurrentValue = ((EFClient.Permission)e.Extra).ToString()
|
||||
};
|
||||
break;
|
||||
default:
|
||||
case GameEvent.EventType.Login:
|
||||
change = new EFChangeHistory()
|
||||
{
|
||||
OriginEntityId = e.Origin.ClientId,
|
||||
Comment = "Logged In To Webfront",
|
||||
TypeOfChange = EFChangeHistory.ChangeType.Command,
|
||||
CurrentValue = e.Data
|
||||
};
|
||||
break;
|
||||
case GameEvent.EventType.Logout:
|
||||
change = new EFChangeHistory()
|
||||
{
|
||||
OriginEntityId = e.Origin.ClientId,
|
||||
Comment = "Logged Out of Webfront",
|
||||
TypeOfChange = EFChangeHistory.ChangeType.Command,
|
||||
CurrentValue = e.Data
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -120,6 +120,14 @@ namespace WebfrontCore.Controllers.API
|
||||
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();
|
||||
|
@ -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;
|
||||
|
||||
@ -51,6 +52,14 @@ namespace WebfrontCore.Controllers
|
||||
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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user