diff --git a/ProjectLighthouse/Controllers/LoginController.cs b/ProjectLighthouse/Controllers/LoginController.cs index 85c04ef5..02ed9740 100644 --- a/ProjectLighthouse/Controllers/LoginController.cs +++ b/ProjectLighthouse/Controllers/LoginController.cs @@ -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() diff --git a/ProjectLighthouse/Controllers/MessageController.cs b/ProjectLighthouse/Controllers/MessageController.cs index c6c55721..3a339632 100644 --- a/ProjectLighthouse/Controllers/MessageController.cs +++ b/ProjectLighthouse/Controllers/MessageController.cs @@ -34,8 +34,18 @@ namespace LBPUnion.ProjectLighthouse.Controllers [HttpGet("announce")] public async Task 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 (