Initial Commit
This commit is contained in:
35
profile.php
Normal file
35
profile.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?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/auth/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>
|
Reference in New Issue
Block a user