Files
Surillya-Login/profile.php

36 lines
830 B
PHP
Raw Permalink Normal View History

2025-05-16 13:58:39 -04:00
<?php
session_start();
$token = $_SESSION['access_token'] ?? $_COOKIE['access_token'] ?? null;
if (!$token) {
header("Location: index.php");
exit;
}
// Get user info
2025-05-16 16:04:02 -04:00
$ch = curl_init('https://surillya.com/id/userinfo.php');
2025-05-16 13:58:39 -04:00
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>