Merge branch 'main' into mod-panel

This commit is contained in:
jvyden 2022-06-17 19:55:15 -04:00
commit f40c6ce894
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
27 changed files with 150 additions and 151 deletions

View file

@ -32,15 +32,8 @@ public class AutoApprovalController : ControllerBase
if (authAttempt.GameToken.UserId != user.UserId) return this.Redirect("/login");
authAttempt.GameToken.Approved = true;
UserApprovedIpAddress approvedIpAddress = new()
{
UserId = user.UserId,
User = user,
IpAddress = authAttempt.IPAddress,
};
this.database.UserApprovedIpAddresses.Add(approvedIpAddress);
user.ApprovedIPAddress = authAttempt.IPAddress;
this.database.AuthenticationAttempts.Remove(authAttempt);
await this.database.SaveChangesAsync();
@ -48,20 +41,16 @@ public class AutoApprovalController : ControllerBase
return this.Redirect("/authentication");
}
[HttpGet("revokeAutoApproval/{id:int}")]
public async Task<IActionResult> RevokeAutoApproval([FromRoute] int id)
[HttpGet("revokeAutoApproval")]
public async Task<IActionResult> RevokeAutoApproval()
{
User? user = this.database.UserFromWebRequest(this.Request);
if (user == null) return this.Redirect("/login");
UserApprovedIpAddress? approvedIpAddress = await this.database.UserApprovedIpAddresses.FirstOrDefaultAsync(a => a.UserApprovedIpAddressId == id);
if (approvedIpAddress == null) return this.BadRequest();
if (approvedIpAddress.UserId != user.UserId) return this.Redirect("/login");
this.database.UserApprovedIpAddresses.Remove(approvedIpAddress);
user.ApprovedIPAddress = null;
await this.database.SaveChangesAsync();
return this.Redirect("/authentication/autoApprovals");
return this.Redirect("/authentication");
}
}