52 lines
1.3 KiB
HTML
52 lines
1.3 KiB
HTML
<!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>
|