fix remove code check fake location
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m12s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 2m12s
This commit is contained in:
parent
02f1fd417d
commit
7edfaa4e4f
4 changed files with 157 additions and 579 deletions
|
|
@ -8,7 +8,6 @@ import config from '@/app.config'
|
|||
import http from '@/plugins/http'
|
||||
import { useCounterMixin } from '@/stores/mixin'
|
||||
import { usePermissions } from '@/composables/usePermissions'
|
||||
import { useLocationValidation } from '@/composables/useLocationValidation'
|
||||
import { usePrivacyStore } from '@/stores/privacy'
|
||||
|
||||
import type { FormRef, OptionReason } from '@/interface/response/checkin'
|
||||
|
|
@ -19,8 +18,6 @@ const mixin = useCounterMixin()
|
|||
const { date2Thai, showLoader, hideLoader, messageError, dialogConfirm } = mixin
|
||||
const $q = useQuasar()
|
||||
const { checkPrivacyAccepted } = usePermissions()
|
||||
const { validateLocation, showMockWarning, resetValidation } =
|
||||
useLocationValidation()
|
||||
const privacyStore = usePrivacyStore()
|
||||
const MOCK_CHECK_DELAY_MS = 800
|
||||
|
||||
|
|
@ -36,8 +33,6 @@ const endTimeAfternoon = ref<string>('12:00:00') //เวลาเช็คเ
|
|||
|
||||
const isLoadingCheckTime = ref<boolean>(false) // ตัวแปรสำหรับการโหลด
|
||||
const disabledBtn = ref<boolean>(false)
|
||||
const locationGranted = ref<boolean>(false)
|
||||
const isMockLocationDetected = ref<boolean>(false)
|
||||
|
||||
/**
|
||||
* fetch เช็คเวลาต้องลงเวลาเข้าหรือออกงาน
|
||||
|
|
@ -119,26 +114,7 @@ async function updateLocation(
|
|||
formLocation.POI = namePOI
|
||||
}
|
||||
|
||||
/**
|
||||
* รับค่าสถานะ location จาก AscGISMap
|
||||
*/
|
||||
function onLocationStatus(status: boolean) {
|
||||
locationGranted.value = status
|
||||
if (status) {
|
||||
isMockLocationDetected.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* รับค่า mock location detection จาก AscGISMap
|
||||
*/
|
||||
function onMockDetected(result: any) {
|
||||
isMockLocationDetected.value = !!result?.isMockDetected
|
||||
disabledBtn.value = false
|
||||
}
|
||||
|
||||
function resetLocationForRetry() {
|
||||
locationGranted.value = false
|
||||
formLocation.lat = 0
|
||||
formLocation.lng = 0
|
||||
formLocation.POI = ''
|
||||
|
|
@ -174,62 +150,6 @@ async function getDelayedFreshPosition() {
|
|||
}
|
||||
}
|
||||
|
||||
async function revalidateLocationBeforeSubmit() {
|
||||
if (!navigator.geolocation) {
|
||||
messageError(
|
||||
$q,
|
||||
'',
|
||||
'ไม่สามารถระบุตำแหน่งปัจจุบันได้ เบราว์เซอร์ของคุณไม่รองรับ Geolocation'
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
try {
|
||||
// If previous attempt was mock, clear history so fresh GPS is not compared
|
||||
// against spoofed coordinates and incorrectly flagged as impossible speed.
|
||||
if (isMockLocationDetected.value) {
|
||||
resetValidation()
|
||||
}
|
||||
|
||||
const position = await getDelayedFreshPosition()
|
||||
|
||||
const validationResult = validateLocation(position)
|
||||
|
||||
if (validationResult.isMockDetected) {
|
||||
isMockLocationDetected.value = true
|
||||
disabledBtn.value = false
|
||||
resetValidation()
|
||||
resetLocationForRetry()
|
||||
showMockWarning(validationResult)
|
||||
mapRef.value?.requestLocationPermission()
|
||||
return false
|
||||
}
|
||||
|
||||
if (validationResult.errors.length > 0) {
|
||||
disabledBtn.value = false
|
||||
resetValidation()
|
||||
resetLocationForRetry()
|
||||
messageError($q, '', validationResult.errors[0])
|
||||
mapRef.value?.requestLocationPermission()
|
||||
return false
|
||||
}
|
||||
|
||||
locationGranted.value = true
|
||||
isMockLocationDetected.value = false
|
||||
return true
|
||||
} catch (error) {
|
||||
disabledBtn.value = false
|
||||
resetLocationForRetry()
|
||||
messageError(
|
||||
$q,
|
||||
'',
|
||||
'ไม่สามารถตรวจสอบตำแหน่งล่าสุดก่อนลงเวลาได้ กรุณาลองใหม่อีกครั้ง'
|
||||
)
|
||||
mapRef.value?.requestLocationPermission()
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
const location = ref<string>('') // พื้นที่ใกล้เคียง
|
||||
const model = ref<string>('') // สถานที่ทำงาน
|
||||
// ตัวเลือกสถานที่ทำงาน
|
||||
|
|
@ -462,11 +382,6 @@ async function validateForm() {
|
|||
}
|
||||
}
|
||||
if (hasError.every((result) => result === true)) {
|
||||
const isLocationValid = await revalidateLocationBeforeSubmit()
|
||||
if (!isLocationValid) {
|
||||
return
|
||||
}
|
||||
|
||||
if (statusCheckin.value == false) {
|
||||
getCheck()
|
||||
} else if (statusCheckin.value) {
|
||||
|
|
@ -511,11 +426,6 @@ async function confirm() {
|
|||
return
|
||||
}
|
||||
|
||||
const isLocationValid = await revalidateLocationBeforeSubmit()
|
||||
if (!isLocationValid) {
|
||||
return
|
||||
}
|
||||
|
||||
showLoader()
|
||||
const isLocation = workplace.value === 'in-place' //*true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง
|
||||
const locationName = workplace.value === 'in-place' ? '' : useLocation.value
|
||||
|
|
@ -734,16 +644,6 @@ watch(
|
|||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(
|
||||
() => locationGranted.value,
|
||||
(newVal) => {
|
||||
// Removed auto-reset of isMockLocationDetected to prevent
|
||||
// clearing mock detection state when permission is granted.
|
||||
// Mock detection state should only be reset after explicit user action
|
||||
// or after a successful validation without mock indicators.
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -816,8 +716,6 @@ watch(
|
|||
v-if="$q.screen.gt.xs"
|
||||
ref="mapRef"
|
||||
@update:location="updateLocation"
|
||||
@location-status="onLocationStatus"
|
||||
@mock-detected="onMockDetected"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -984,12 +882,7 @@ watch(
|
|||
</div>
|
||||
|
||||
<div class="col-12" v-if="$q.screen.xs">
|
||||
<MapCheck
|
||||
ref="mapRef"
|
||||
@update:location="updateLocation"
|
||||
@location-status="onLocationStatus"
|
||||
@mock-detected="onMockDetected"
|
||||
/>
|
||||
<MapCheck ref="mapRef" @update:location="updateLocation" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- กรอกข้อมูล หน้ามือถือ -->
|
||||
|
|
@ -1138,13 +1031,7 @@ watch(
|
|||
push
|
||||
size="18px"
|
||||
:class="$q.screen.gt.xs ? 'q-px-md' : 'full-width q-pa-sm'"
|
||||
:disable="
|
||||
disabledBtn || !locationGranted || isMockLocationDetected
|
||||
? true
|
||||
: camera && img
|
||||
? false
|
||||
: true
|
||||
"
|
||||
:disable="disabledBtn ? true : camera && img ? false : true"
|
||||
@click="validateForm"
|
||||
:loading="inQueue"
|
||||
/>
|
||||
|
|
@ -1259,13 +1146,7 @@ watch(
|
|||
push
|
||||
size="18px"
|
||||
:class="$q.screen.gt.xs ? 'q-px-md' : 'full-width q-pa-sm'"
|
||||
:disable="
|
||||
disabledBtn || !locationGranted || isMockLocationDetected
|
||||
? true
|
||||
: camera && img
|
||||
? false
|
||||
: true
|
||||
"
|
||||
:disable="disabledBtn ? true : camera && img ? false : true"
|
||||
@click="validateForm"
|
||||
:loading="inQueue"
|
||||
/>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue