Spaces:
Sleeping
Sleeping
File size: 863 Bytes
985eaab | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | <!DOCTYPE html>
<html>
<head>
<title>Google OAuth Demo</title>
</head>
<body>
<h1>Google Login Demo</h1>
<div id="welcome-message">Checking login...</div>
<button onclick="loginWithGoogle()">Login with Google</button>
<script>
async function checkLogin() {
try {
const res = await fetch("/api/user");
if (res.ok) {
const user = await res.json();
document.getElementById("welcome-message").innerText =
`Welcome, ${user.name} (${user.email})`;
} else {
document.getElementById("welcome-message").innerText =
"You are not logged in.";
}
} catch (err) {
console.error("Error checking login:", err);
}
}
function loginWithGoogle() {
window.location.href = "/google/login";
}
checkLogin();
</script>
</body>
</html>
|