get the right redirected ip

This commit is contained in:
Parsa Nazer
2025-02-21 01:32:45 +03:30
parent a2542ec709
commit 258b72bafc
+8
View File
@@ -267,11 +267,19 @@ class FakeAdminLoginView(View):
return context
def get(self, request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get("REMOTE_ADDR")
hacker, created = SecurityBreachAttemptModel.objects.get_or_create(ip=ip)
return render(request, 'admin/fake_login.html', self.get_context(request))
def post(self, request):
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
if x_forwarded_for:
ip = x_forwarded_for.split(',')[0]
else:
ip = request.META.get("REMOTE_ADDR")
hacker, created = SecurityBreachAttemptModel.objects.get_or_create(ip=ip)
hacker.trys += 1