Files
gravity/จัดการข้อมูล Line KSH-STAFF/liff/api_login.php
T
2026-09-16 23:20:08 +07:00

30 lines
825 B
PHP

<?php
// liff/api_login.php
session_start();
require_once '../includes/db.php';
header('Content-Type: application/json');
$input = json_decode(file_get_contents('php://input'), true);
$line_uid = $input['line_uid'] ?? '';
if (empty($line_uid)) {
echo json_encode(['status' => 'error', 'message' => 'No Line UID provided']);
exit;
}
// Check if this Line UID is already in the system and active
$stmt = $pdo_bot->prepare("SELECT * FROM line_staff_register WHERE user_id = ? AND ksh_user = 'Y'");
$stmt->execute([$line_uid]);
$staff = $stmt->fetch();
if ($staff) {
// User exists, set session
$_SESSION['cid'] = $staff['cid'];
echo json_encode(['status' => 'success', 'redirect' => 'index.php']);
} else {
// User not found, needs registration
echo json_encode(['status' => 'not_found']);
}
?>