Pembaruan Link generate WA #41

Merged
arbi merged 1 commits from development into main 2026-09-30 11:59:14 +07:00
+20 -1
View File
@@ -3,7 +3,10 @@
namespace App\Services;
use App\Models\Verifikator\VerifikasiAbsenToken;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Str;
class VerifikasiAbsenLinkService
@@ -118,7 +121,23 @@ class VerifikasiAbsenLinkService
return null;
}
return $this->buatToken($pengajuanId, $row->nip, $row->expires_at);
// Token pengganti yang sesinya masih jalan dipakai ulang, jangan buat baru tiap tombol WA diklik.
// Token di DB hanya berupa hash, jadi plaintext pengganti disimpan (terenkripsi) di cache selama sesinya.
$kunciCache = "verifikasi-absen:pengganti:{$row->id}";
if ($tersimpan = Cache::get($kunciCache)) {
try {
return Crypt::decryptString($tersimpan);
} catch (DecryptException) {
Cache::forget($kunciCache);
}
}
$tokenBaru = $this->buatToken($pengajuanId, $row->nip, $row->expires_at);
Cache::put($kunciCache, Crypt::encryptString($tokenBaru), now()->addMinutes(self::SESI_MENIT));
return $tokenBaru;
}
public function markUsed(int $pengajuanId, string $token): void