36 lines
830 B
PHP
36 lines
830 B
PHP
<?php
|
|
session_start();
|
|
|
|
$token = $_SESSION['access_token'] ?? $_COOKIE['access_token'] ?? null;
|
|
|
|
if (!$token) {
|
|
header("Location: index.php");
|
|
exit;
|
|
}
|
|
|
|
// Get user info
|
|
$ch = curl_init('https://surillya.com/id/userinfo.php');
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, [
|
|
"Authorization: Bearer $token"
|
|
]);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
$user_response = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
$user = json_decode($user_response, true);
|
|
|
|
if (!$user) {
|
|
echo "Invalid token or failed to fetch user.";
|
|
exit;
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head><title>Welcome, <?= htmlspecialchars($user['name']) ?>!</title></head>
|
|
<body>
|
|
<h1>Hello, <?= htmlspecialchars($user['name']) ?>!</h1>
|
|
<p>Email: <?= htmlspecialchars($user['email']) ?></p>
|
|
<a href="logout.php"><button>Log out</button></a>
|
|
</body>
|
|
</html>
|