update
This commit is contained in:
61
app/templates/login.html
Normal file
61
app/templates/login.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Tidal DL - Login</title>
|
||||
<link rel="stylesheet" href="/static/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>Tidal DL Web</h1>
|
||||
<div class="card">
|
||||
<h2>Login Required</h2>
|
||||
<p>Please login to your Tidal account to continue.</p>
|
||||
<div id="login-step-1">
|
||||
<button onclick="startLogin()">Start Device Login</button>
|
||||
</div>
|
||||
<div id="login-step-2" style="display:none;">
|
||||
<p id="login-message">Initializing...</p>
|
||||
<p>Link: <a id="login-link" href="#" target="_blank">Open Tidal Login</a></p>
|
||||
<p>Code: <strong id="login-code"></strong></p>
|
||||
<div id="spinner">Waiting for you to login...</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
async function startLogin() {
|
||||
document.getElementById('login-step-1').style.display = 'none';
|
||||
document.getElementById('login-step-2').style.display = 'block';
|
||||
|
||||
const response = await fetch('/auth/start', { method: 'POST' });
|
||||
const data = await response.json();
|
||||
updateStatus(data);
|
||||
|
||||
// Poll status
|
||||
setInterval(checkStatus, 2000);
|
||||
}
|
||||
|
||||
async function checkStatus() {
|
||||
const response = await fetch('/auth/status');
|
||||
const data = await response.json();
|
||||
updateStatus(data);
|
||||
|
||||
if (data.status === 'success') {
|
||||
window.location.href = '/';
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus(data) {
|
||||
document.getElementById('login-message').innerText = data.message;
|
||||
if (data.link) {
|
||||
document.getElementById('login-link').href = data.link;
|
||||
document.getElementById('login-link').innerText = data.link;
|
||||
}
|
||||
// If code is part of message or separate, handle it.
|
||||
// Our backend might not parse code perfectly yet, but message usually contains it.
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user