summaryrefslogtreecommitdiffstatshomepage
path: root/ui/src
diff options
context:
space:
mode:
authorHsiangNianian <i@jyunko.cn>2026-01-13 19:48:27 +0800
committerHsiangNianian <i@jyunko.cn>2026-01-13 19:48:27 +0800
commit4f2abfdaa35d43a8d3ec868a1b27f6f8d0ebf547 (patch)
treef69b161804ec977943b921c775ca8c0cbb6de4c9 /ui/src
parent203c24d2da82841cae0b5c29708d07ebce1efb85 (diff)
downloadDropOut-4f2abfdaa35d43a8d3ec868a1b27f6f8d0ebf547.tar.gz
DropOut-4f2abfdaa35d43a8d3ec868a1b27f6f8d0ebf547.zip
feat: enhance Microsoft login flow with status updates and polling management
Diffstat (limited to 'ui/src')
-rw-r--r--ui/src/App.svelte19
1 files changed, 13 insertions, 6 deletions
diff --git a/ui/src/App.svelte b/ui/src/App.svelte
index 914a5ea..beb3403 100644
--- a/ui/src/App.svelte
+++ b/ui/src/App.svelte
@@ -64,6 +64,8 @@
let offlineUsername = "";
let deviceCodeData: DeviceCodeResponse | null = null;
let msLoginLoading = false;
+ let msLoginStatus = "Waiting for authorization...";
+ let isPollingRequestActive = false;
onMount(async () => {
checkAccount();
@@ -126,6 +128,7 @@
}
function closeLoginModal() {
+ stopPolling();
isLoginModalOpen = false;
}
@@ -154,6 +157,7 @@
async function startMicrosoftLogin() {
loginMode = "microsoft";
msLoginLoading = true;
+ msLoginStatus = "Waiting for authorization...";
stopPolling(); // Ensure no duplicates
try {
@@ -188,6 +192,9 @@
}
async function checkLoginStatus(deviceCode: string) {
+ if (isPollingRequestActive) return;
+ isPollingRequestActive = true;
+
console.log("Polling Microsoft API...");
try {
// This will fail with "authorization_pending" until user logs in
@@ -204,9 +211,12 @@
const errStr = e.toString();
if (errStr.includes("authorization_pending")) {
console.log("Status: Waiting for user to authorize...");
+ // Keep checking
} else {
// Real error
console.error("Polling Error:", errStr);
+ msLoginStatus = "Error: " + errStr;
+
// Optional: Stop polling on fatal errors?
// expired_token should stop it.
if (
@@ -218,6 +228,8 @@
loginMode = "select";
}
}
+ } finally {
+ isPollingRequestActive = false;
}
}
@@ -226,11 +238,6 @@
if (deviceCodeData) checkLoginStatus(deviceCodeData.device_code);
}
- function closeLoginModal() {
- stopPolling();
- isLoginModalOpen = false;
- }
-
function openLink(url: string) {
open(url);
}
@@ -669,7 +676,7 @@
<div class="pt-6 space-y-3">
<div class="flex flex-col items-center gap-3">
<div class="animate-spin rounded-full h-6 w-6 border-2 border-zinc-600 border-t-indigo-500"></div>
- <span class="text-sm text-zinc-400 font-medium">Waiting for authorization...</span>
+ <span class="text-sm text-zinc-400 font-medium break-all text-center">{msLoginStatus}</span>
</div>
<p class="text-xs text-zinc-600">This window will update automatically.</p>
</div>