Update frontend/index.html
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
efa4c9c3cd
commit
426e3af0f6
+21
-5
@@ -73,11 +73,27 @@
|
|||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
const data = await resp.json();
|
const data = await resp.json();
|
||||||
// data.picture is expected to be a Gravatar URL
|
// data.picture is expected to be a Gravatar URL
|
||||||
document.getElementById("authSection").innerHTML = `
|
const authSection = document.getElementById("authSection");
|
||||||
<img src="${data.picture}" alt="User Avatar" class="inline-block h-8 w-8 rounded-full mr-2">
|
authSection.innerHTML = '';
|
||||||
Logged in as <strong>${data.email}</strong>
|
|
||||||
<a href="/logout" class="ml-4 text-blue-600 hover:text-blue-800">Logout</a>
|
const img = document.createElement('img');
|
||||||
`;
|
img.src = data.picture;
|
||||||
|
img.alt = 'User Avatar';
|
||||||
|
img.className = 'inline-block h-8 w-8 rounded-full mr-2';
|
||||||
|
|
||||||
|
const textNode = document.createTextNode('Logged in as ');
|
||||||
|
const strong = document.createElement('strong');
|
||||||
|
strong.textContent = data.email;
|
||||||
|
|
||||||
|
const logoutLink = document.createElement('a');
|
||||||
|
logoutLink.href = '/logout';
|
||||||
|
logoutLink.className = 'ml-4 text-blue-600 hover:text-blue-800';
|
||||||
|
logoutLink.textContent = 'Logout';
|
||||||
|
|
||||||
|
authSection.appendChild(img);
|
||||||
|
authSection.appendChild(textNode);
|
||||||
|
authSection.appendChild(strong);
|
||||||
|
authSection.appendChild(logoutLink);
|
||||||
} else {
|
} else {
|
||||||
document.getElementById("authSection").innerHTML =
|
document.getElementById("authSection").innerHTML =
|
||||||
`<a href="/login" class="text-blue-600">Login</a>`;
|
`<a href="/login" class="text-blue-600">Login</a>`;
|
||||||
|
|||||||
Reference in New Issue
Block a user