49 lines
1.6 KiB
PHP
49 lines
1.6 KiB
PHP
<?php
|
|
session_start();
|
|
include 'koneksi.php';
|
|
header('Content-Type: application/json');
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Sesi login tidak ditemukan. Silakan login ulang.']);
|
|
exit;
|
|
}
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
|
echo json_encode(['status' => 'error', 'message' => 'Invalid method']);
|
|
exit;
|
|
}
|
|
|
|
$credential_id = $_POST['credential_id'] ?? '';
|
|
file_put_contents('debug_passkey.txt', "VERIFY PASSKEY - Received credential_id: " . $credential_id . " (Length: " . strlen($credential_id) . ")\n", FILE_APPEND);
|
|
|
|
if (empty($credential_id)) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Credential ID kosong / Tidak ada sidik jari yang terdeteksi']);
|
|
exit;
|
|
}
|
|
|
|
$userId = $_SESSION['user_id'];
|
|
|
|
try {
|
|
$stmt = $pdo->prepare("SELECT id_account, name, username, status FROM account WHERE finger_id = ? AND id_account = ?");
|
|
$stmt->execute([$credential_id, $userId]);
|
|
$account = $stmt->fetch();
|
|
|
|
if ($account) {
|
|
if ($account['status'] !== 'approved') {
|
|
echo json_encode(['status' => 'error', 'message' => 'Akses ditolak: Menunggu Persetujuan Dari Admin']);
|
|
} else {
|
|
echo json_encode([
|
|
'status' => 'success',
|
|
'message' => 'Terverifikasi',
|
|
'name' => htmlspecialchars($account['name'])
|
|
]);
|
|
}
|
|
} else {
|
|
echo json_encode(['status' => 'error', 'message' => 'Sidik jari tidak terdaftar di sistem.']);
|
|
}
|
|
|
|
} catch (PDOException $e) {
|
|
echo json_encode(['status' => 'error', 'message' => 'Kesalahan database: ' . $e->getMessage()]);
|
|
}
|
|
?>
|