diff options
| author | 2026-01-16 09:37:20 +0800 | |
|---|---|---|
| committer | 2026-01-16 09:37:20 +0800 | |
| commit | ad36e0ce82770f9b3509ddb1cf96bc3422969806 (patch) | |
| tree | 6df911b964d0d32facf55844c55e61ba3878ae3f /ui/src/stores/auth.svelte.ts | |
| parent | 455da9d2b07d05c2bdd1fffa5031a6a329cc5643 (diff) | |
| parent | 963b4b8567ac1bd8b23c41e1bfbd6a99d202d1ed (diff) | |
| download | DropOut-ad36e0ce82770f9b3509ddb1cf96bc3422969806.tar.gz DropOut-ad36e0ce82770f9b3509ddb1cf96bc3422969806.zip | |
Merge pull request #41 from HsiangNianian/main
Diffstat (limited to 'ui/src/stores/auth.svelte.ts')
| -rw-r--r-- | ui/src/stores/auth.svelte.ts | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/ui/src/stores/auth.svelte.ts b/ui/src/stores/auth.svelte.ts index eb9dccd..1b613a7 100644 --- a/ui/src/stores/auth.svelte.ts +++ b/ui/src/stores/auth.svelte.ts @@ -14,7 +14,7 @@ export class AuthState { deviceCodeData = $state<DeviceCodeResponse | null>(null); msLoginLoading = $state(false); msLoginStatus = $state("Waiting for authorization..."); - + private pollInterval: ReturnType<typeof setInterval> | null = null; private isPollingRequestActive = false; private authProgressUnlisten: UnlistenFn | null = null; @@ -87,9 +87,7 @@ export class AuthState { this.setupAuthProgressListener(); try { - this.deviceCodeData = (await invoke( - "start_microsoft_login" - )) as DeviceCodeResponse; + this.deviceCodeData = (await invoke("start_microsoft_login")) as DeviceCodeResponse; if (this.deviceCodeData) { try { @@ -99,13 +97,17 @@ export class AuthState { } open(this.deviceCodeData.verification_uri); - logsState.addLog("info", "Auth", "Microsoft login started, waiting for browser authorization..."); + logsState.addLog( + "info", + "Auth", + "Microsoft login started, waiting for browser authorization...", + ); console.log("Starting polling for token..."); const intervalMs = (this.deviceCodeData.interval || 5) * 1000; this.pollInterval = setInterval( () => this.checkLoginStatus(this.deviceCodeData!.device_code), - intervalMs + intervalMs, ); } } catch (e) { @@ -159,7 +161,11 @@ export class AuthState { this.stopPolling(); this.cleanupAuthListener(); this.isLoginModalOpen = false; - logsState.addLog("info", "Auth", `Login successful! Welcome, ${this.currentAccount.username}`); + logsState.addLog( + "info", + "Auth", + `Login successful! Welcome, ${this.currentAccount.username}`, + ); uiState.setStatus("Welcome back, " + this.currentAccount.username); } catch (e: any) { const errStr = e.toString(); @@ -169,11 +175,8 @@ export class AuthState { console.error("Polling Error:", errStr); this.msLoginStatus = "Error: " + errStr; logsState.addLog("error", "Auth", `Login error: ${errStr}`); - - if ( - errStr.includes("expired_token") || - errStr.includes("access_denied") - ) { + + if (errStr.includes("expired_token") || errStr.includes("access_denied")) { this.stopPolling(); this.cleanupAuthListener(); alert("Login failed: " + errStr); |