Use dynamic redirectUri
This commit is contained in:
@@ -1,20 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>登入 | 喚醒 {{COMPUTER_NAME}}</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif; padding: 1.5rem; font-size: 1.2rem;
|
||||
font-family: sans-serif;
|
||||
padding: 1.5rem;
|
||||
font-size: 1.2rem;
|
||||
}
|
||||
a, button {
|
||||
|
||||
a,
|
||||
button {
|
||||
font-size: 1.1rem;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>喚醒 {{COMPUTER_NAME}}</h1>
|
||||
<a href="/login">點此登入</a>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user