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