added gravatar to user and added /api/whoami call

This commit is contained in:
Christian Krakau-Louis
2025-03-25 21:31:32 +01:00
parent 657861db26
commit e4101f690b
3 changed files with 56 additions and 3 deletions
+6 -2
View File
@@ -124,8 +124,12 @@
const resp = await fetch("/api/whoami");
if (resp.ok) {
const data = await resp.json();
document.getElementById("authSection").innerHTML =
`Logged in as <strong>${data.email}</strong> <a href="/logout" class="ml-2 text-blue-600">Logout</a>`;
// data.picture is the Gravatar URL
document.getElementById("authSection").innerHTML = `
<img src="${data.picture}" alt="User Avatar" class="inline-block h-8 w-8 rounded-full mr-2">
Logged in as <strong>${data.email}</strong>
<a href="/logout" class="ml-4 text-blue-600 hover:text-blue-800">Logout</a>
`;
} else {
// If 401 or other non-OK status => show Login link
document.getElementById("authSection").innerHTML =