Show debug info on announce screen

This commit is contained in:
jvyden 2021-12-13 20:52:58 -05:00 committed by LumaLivy
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 // Get an existing token from the IP & username
GameToken? token = await this.database.GameTokens.Include GameToken? token = await this.database.GameTokens.Include
(t => t.User) (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 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 if (this.database.UserApprovedIpAddresses.Where(a => a.UserId == user.UserId).Select(a => a.IpAddress).Contains(ipAddress))
(a => a.UserId == user.UserId) {
.Select(a => a.IpAddress) token.Approved = true;
.Contains(ipAddress)) token.Approved = true; }
else else
{ {
AuthenticationAttempt authAttempt = new() AuthenticationAttempt authAttempt = new()

View file

@ -34,8 +34,18 @@ namespace LBPUnion.ProjectLighthouse.Controllers
[HttpGet("announce")] [HttpGet("announce")]
public async Task<IActionResult> Announce() public async Task<IActionResult> Announce()
{ {
#if !DEBUG
User? user = await this.database.UserFromGameRequest(this.Request); User? user = await this.database.UserFromGameRequest(this.Request);
if (user == null) return this.StatusCode(403, ""); 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 return this.Ok
( (