Added Device and UserIp models and migrations to store device fingerprints and user IPs with expiration. Updated ShowSavingIp Livewire component and view to capture and persist both IP and device fingerprint. Introduced a scheduled command to clean expired user IPs and registered it in the console kernel. Removed the old migration for storing IPs directly on the users table.
36 lines
1.1 KiB
PHP
36 lines
1.1 KiB
PHP
<div
|
|
x-data="{
|
|
async getData() {
|
|
try {
|
|
// Obtener IP pública
|
|
const ipRes = await fetch('https://api.ipify.org/?format=json');
|
|
const ipData = await ipRes.json();
|
|
|
|
// Cargar librería Fingerprint
|
|
const fpModule = await import('https://openfpcdn.io/fingerprintjs/v3');
|
|
const fp = await fpModule.load();
|
|
const result = await fp.get();
|
|
|
|
const fingerprint = result.visitorId;
|
|
|
|
// Emitir ambos valores a Livewire
|
|
$wire.emit('setDeviceData', { ip: ipData.ip, fingerprint });
|
|
} catch (e) {
|
|
console.error('Error obteniendo IP/Fingerprint:', e);
|
|
}
|
|
}
|
|
}"
|
|
x-init="getData()"
|
|
wire:poll.visible.delay.600000ms
|
|
class="py-4"
|
|
>
|
|
<p class="text-sm text-gray-600">
|
|
@if($ip_address)
|
|
Tu IP actual: <strong>{{ $ip_address }}</strong><br>
|
|
ID del dispositivo: <strong>{{ $device_fingerprint }}</strong>
|
|
@else
|
|
Obteniendo IP y dispositivo...
|
|
@endif
|
|
</p>
|
|
</div>
|