Show debug info on announce screen

This commit is contained in:
jvyden 2021-12-13 20:52:58 -05:00 committed by LumaLivy
parent ea6af58aa0
commit 55707e9e3e
2 changed files with 15 additions and 5 deletions

View file

@ -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()

View file

@ -34,8 +34,18 @@ 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);
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
(