Enforce browser location for geo fenced attendance

This commit is contained in:
A R R R Associates
2026-07-06 16:42:29 +05:30
parent 61930616bf
commit eb1cf6cbf2
3 changed files with 40 additions and 10 deletions
@@ -26,7 +26,7 @@
Click Punch In/Punch Out. The app will ask for browser location before submitting attendance.
</div>
<div class="mt-2 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800">
If branch geofence/IP verification is not configured, attendance may be approved without location check. Configure branch attendance geo/IP settings to enforce verification.
When branch geofence is enabled, browser location is mandatory. If location is denied/unavailable, attendance will not be submitted.
</div>
<div class="mt-4 grid gap-3 md:grid-cols-2 xl:grid-cols-1">
@@ -61,8 +61,7 @@
Click Continue, then choose <strong>Allow</strong> in the browser location popup.
</p>
<p class="mt-3 text-xs leading-5 text-slate-500">
If you are outside the branch or location is denied/unavailable, your attendance can still be saved.
It will require approval only when branch geofence/IP verification is configured.
If you are outside the branch, attendance will require approval. If browser location is denied/unavailable while branch geofence is enabled, attendance will not be submitted.
</p>
</div>
</div>
@@ -134,7 +133,7 @@ window.EmployeePortalGeo = window.EmployeePortalGeo || (function () {
return new Promise(function (resolve) {
if (!navigator.geolocation) {
setHidden(form, '', '', '');
updateStatus('Browser geolocation is not available. Attendance can be saved, but geofence verification cannot be performed.', 'warn');
updateStatus('Browser geolocation is not available. Attendance was not submitted. Enable browser/device location and try again.', 'warn');
resolve(false);
return;
}
@@ -150,7 +149,7 @@ window.EmployeePortalGeo = window.EmployeePortalGeo || (function () {
if (err && err.code === 1) reason = 'Location permission denied. Allow location for this site in browser settings.';
if (err && err.code === 2) reason = 'Location unavailable. Enable device location service and try again.';
if (err && err.code === 3) reason = 'Location capture timed out. Try again with stable GPS/location service.';
updateStatus(reason + ' Attendance can be saved, but geofence verification cannot be performed.', 'warn');
updateStatus(reason + ' Attendance was not submitted. Please allow browser location/GPS and try again.', 'warn');
resolve(false);
}, { enableHighAccuracy: true, timeout: 20000, maximumAge: 0 });
});
@@ -167,7 +166,11 @@ window.EmployeePortalGeo = window.EmployeePortalGeo || (function () {
var proceed = await openLocationModal();
if (!proceed) return;
await captureLocation(form);
var captured = await captureLocation(form);
if (!captured) {
updateStatus('Attendance not submitted because location was not captured.', 'warn');
return;
}
form.dataset.geoSubmitted = '1';
form.submit();
});