Files
snapcad-studio/api/sync_session.php
T

45 lines
1.4 KiB
PHP
Raw Normal View History

<?php
/**
* SnapCAD — YakNet SSO Oturum Durumu (/api/sync_session.php)
*
* Güvenlik notu: Bu uç nokta istemciden gelen kullanıcı verisini ASLA kabul etmez.
* Oturum yalnızca sunucu taraflı OAuth callback'i (/callback.php) ile kurulur.
* Eski istemci taraflı SSO senkronizasyonu kaldırılmıştır.
*/
require_once __DIR__ . '/../snap-config.php';
header('Content-Type: application/json; charset=utf-8');
header('Cache-Control: no-store, no-cache, must-revalidate, max-age=0');
$action = $_GET['action'] ?? '';
$user = $_SESSION['yaknet_user'] ?? null;
if ($action === 'logout') {
snapcad_logout();
echo json_encode([
'ok' => true,
'success' => true,
'authenticated' => false,
'user' => null,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
if ($action === 'status' || $action === '') {
echo json_encode([
'ok' => true,
'success' => true,
'authenticated' => $user !== null,
'user' => $user,
'guest_student' => $_SESSION['snapcad_guest_student'] ?? null,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
exit;
}
http_response_code(403);
echo json_encode([
'ok' => false,
'success' => false,
'authenticated' => $user !== null,
'error' => 'İstemci taraflı oturum senkronizasyonu devre dışı. Lütfen YakNet hesabınızla giriş yapın.',
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);