mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-24 22:21:30 +00:00
Show debug info on announce screen
This commit is contained in:
parent
78e3bad38e
commit
adb5dbef45
2 changed files with 30 additions and 7 deletions
|
@ -51,7 +51,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
// Get an existing token from the IP & username
|
||||
GameToken? token = await this.database.GameTokens.Include
|
||||
(t => t.User)
|
||||
.FirstOrDefaultAsync(t => t.UserLocation == ipAddress && t.User.Username == loginData.Username && t.Approved && !t.Used);
|
||||
.FirstOrDefaultAsync(t => t.UserLocation == ipAddress && t.User.Username == loginData.Username && !t.Used);
|
||||
|
||||
if (token == null) // If we cant find an existing token, try to generate a new one
|
||||
{
|
||||
|
@ -79,10 +79,10 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
if (this.database.UserApprovedIpAddresses.Where
|
||||
(a => a.UserId == user.UserId)
|
||||
.Select(a => a.IpAddress)
|
||||
.Contains(ipAddress)) token.Approved = true;
|
||||
if (this.database.UserApprovedIpAddresses.Where(a => a.UserId == user.UserId).Select(a => a.IpAddress).Contains(ipAddress))
|
||||
{
|
||||
token.Approved = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
AuthenticationAttempt authAttempt = new()
|
||||
|
|
|
@ -34,10 +34,33 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpGet("announce")]
|
||||
public async Task<IActionResult> Announce()
|
||||
{
|
||||
#if !DEBUG
|
||||
User? user = await this.database.UserFromGameRequest(this.Request);
|
||||
if (user == null) return this.StatusCode(403, "");
|
||||
#else
|
||||
(User, GameToken)? userAndToken = await this.database.UserAndGameTokenFromRequest(this.Request);
|
||||
|
||||
return this.Ok($"You are now logged in as {user.Username} (id: {user.UserId}).\n\n" + ServerSettings.Instance.EulaText);
|
||||
if (userAndToken == null) return this.StatusCode(403, "");
|
||||
|
||||
// ReSharper disable once PossibleInvalidOperationException
|
||||
User user = userAndToken.Value.Item1;
|
||||
GameToken gameToken = userAndToken.Value.Item2;
|
||||
#endif
|
||||
|
||||
return this.Ok
|
||||
(
|
||||
$"You are now logged in as {user.Username}.\n\n" +
|
||||
#if DEBUG
|
||||
"---DEBUG INFO---\n" +
|
||||
$"user.UserId: {user.UserId}\n" +
|
||||
$"token.Approved: {gameToken.Approved}\n" +
|
||||
$"token.Used: {gameToken.Used}\n" +
|
||||
$"token.UserLocation: {gameToken.UserLocation}\n" +
|
||||
$"token.GameVersion: {gameToken.GameVersion}\n" +
|
||||
"---DEBUG INFO---\n\n" +
|
||||
#endif
|
||||
ServerSettings.Instance.EulaText
|
||||
);
|
||||
}
|
||||
|
||||
[HttpGet("notification")]
|
||||
|
@ -49,7 +72,7 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
[HttpPost("filter")]
|
||||
public async Task<IActionResult> Filter()
|
||||
{
|
||||
User user = await this.database.UserFromGameRequest(this.Request);
|
||||
User? user = await this.database.UserFromGameRequest(this.Request);
|
||||
if (user == null) return this.StatusCode(403, "");
|
||||
|
||||
string loggedText = await new StreamReader(this.Request.Body).ReadToEndAsync();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue