[FIX] ATTENDANCE: IP restriction nginx fix
This commit is contained in:
@@ -24,4 +24,4 @@
|
||||
style="color: green"
|
||||
>{% trans "Add more IP address.." %}</a
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<div class="oh-modal__dialog-body">
|
||||
<form class="oh-profile-section" hx-post="{% url 'create-allowed-ip' %}" hx-target="#objectDetailsModalW25Target">
|
||||
{% for field in form.visible_fields %}
|
||||
{{ form.non_field_errors }}
|
||||
{{ form.non_field_errors }}
|
||||
<div
|
||||
class="oh-input__group"
|
||||
id="moreIPContainer_{{ forloop.counter0 }}"
|
||||
@@ -23,7 +23,7 @@
|
||||
{% trans field.label %}
|
||||
</label>
|
||||
{{ field }}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div id="moreIPContainer_{{form.ip_counts}}" class="pt-2" style="text-align: end">
|
||||
<a
|
||||
@@ -42,4 +42,4 @@
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,4 +16,4 @@
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -186,10 +186,13 @@ def clock_in(request):
|
||||
"""
|
||||
allowed_attendance_ips = AttendanceAllowedIP.objects.first()
|
||||
if allowed_attendance_ips and allowed_attendance_ips.is_enabled:
|
||||
if not (
|
||||
request.META.get("REMOTE_ADDR")
|
||||
in allowed_attendance_ips.additional_data["allowed_ips"]
|
||||
):
|
||||
|
||||
x_forwarded_for = request.META.get("HTTP_X_FORWARDED_FOR")
|
||||
ip = request.META.get("REMOTE_ADDR")
|
||||
if x_forwarded_for:
|
||||
ip = x_forwarded_for.split(",")[0]
|
||||
|
||||
if not (ip in allowed_attendance_ips.additional_data["allowed_ips"]):
|
||||
return HttpResponse(_("You cannot mark attendance from this network"))
|
||||
|
||||
employee, work_info = employee_exists(request)
|
||||
|
||||
Reference in New Issue
Block a user