fix(api): получения ip адреса за балансировщиком

This commit is contained in:
Mikhail Trubnikov
2023-12-04 10:56:29 +10:00
parent 68e15021ec
commit 9de290aca6
2 changed files with 13 additions and 3 deletions

View File

@@ -25,7 +25,7 @@ namespace PARR.API.Authentication
var ipClient = Request.HttpContext.Connection.RemoteIpAddress?.MapToIPv4().ToString();
if (ipClient == null)
return AuthenticateResult.Fail($"IP address not defined.");
return AuthenticateResult.Fail($"IP address not defined. IP: {ipClient}");
// Аутентификация - просто проверка, есть ли у нас такой пользователь
using (var scope = serviceProvider.CreateScope())
@@ -34,11 +34,11 @@ namespace PARR.API.Authentication
var userIsBlocked = await authService.UserIsBlockedAsync(ipClient);
if (userIsBlocked)
return AuthenticateResult.Fail($"IP address is on the blocking list.");
return AuthenticateResult.Fail($"IP address is on the blocking list. IP: {ipClient}");
var user = await authService.GetUserAsync(ipClient);
if (user == null)
return AuthenticateResult.Fail($"IP address not defined.");
return AuthenticateResult.Fail($"IP address not defined. IP: {ipClient}");
// пользователь найден, аутентификация пройдена