Repository navigation
feat: automatic portal login after connecting - #34
Merged
Merged
Conversation
Opening the portal (automatically after connect and via the button) now fetches a fresh one-time login link from POST /api/v1/client/portal-link right before opening it. On a non-2xx status, network error, timeout over 5 s, missing url or a url whose scheme/host differs from the configured portal URL, the plain portal URL is opened as before. The link carries a single-use ticket: it is never cached, stored or logged. The once-per-session auto-open gate moved into the ViewModel. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016xX1efcZF1f6G9rhmaJNLD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Opening the portal now logs the user in automatically through a one-time link.
POST /api/v1/client/portal-linkendpoint (ApiClient.requestPortalLink) plus theApiClient.getPortalLink(portalUrl)suspend extension. It returns the link ornull, and never throws.getPortalLinkreturnsnullon any of these: a non-2xx status, a network error or malformed body, no answer within 5 s, a missingurl, or aurlwhose scheme or host differs from the configuredportalUrl.VpnViewModel.openPortal(button) and the newautoOpenPortalIfNeeded(auto-open after connect) fetch a fresh link right before opening. The fetch runs inviewModelScopeand the browser starts on the main thread. If the fetch fails, the plainportalUrlopens as before. A second tap while a fetch is running is ignored.connectedSince) moved fromVpnScreeninto the ViewModel so it can be tested.PortalLinkResponse.toString()masks the URL.Tests
PortalLinkTest(MockWebServer) covers success (POST to the right path), 404, 500, timeout, network error, missing url, malformed body, host mismatch, scheme mismatch and the same-origin rules. It also checks that neither the link nor the ticket shows up in Timber or HTTP (HEADERS level) logs.VpnViewModelTestcovers opening the link, a fresh fetch on every tap, fallback on 404, the 5 s timeout, host mismatch and network errors, ignoring a double tap, auto-open hitting the endpoint once per session (and again for a new session), and no auto-open when it is disabled or the tunnel is not connected../gradlew test lintReleasepasses locally.🤖 Generated with Claude Code
https://claude.ai/code/session_016xX1efcZF1f6G9rhmaJNLD
Generated by Claude Code