Initialize

This commit is contained in:
2025-10-24 22:07:49 +08:00
commit 233f3fe40e
13 changed files with 1580 additions and 0 deletions

51
templates/login.html Normal file
View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>登入 | TutorOTP</title>
<style>
body {
font-family: sans-serif;
padding: 1.5rem;
font-size: 1.2rem;
}
a,
button {
font-size: 1.1rem;
}
</style>
</head>
<body>
<h1>TutorOTP</h1>
<button id="loginBtn">登入</button>
<script>
document.getElementById('loginBtn').addEventListener('click', async function () {
const redirectUri = window.location.origin + '/callback';
try {
const res = await fetch('/authorize', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ redirectUri })
});
if (!res.ok) {
alert('伺服器錯誤');
return;
}
const data = await res.json();
if (data && data.redirect) {
window.location.href = data.redirect;
}
} catch (err) {
alert('請求失敗: ' + err);
}
});
</script>
</body>
</html>