Skip to content

Commit 2012727

Browse files
committed
fix: prompt for sign in when toggling coder connect on
1 parent ebcb698 commit 2012727

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

Coder-Desktop/Coder-Desktop/Views/VPN/VPNMenu.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,15 @@ struct VPNMenu<VPN: VPNService, FS: FileSyncDaemon>: View {
117117
}
118118

119119
private var vpnDisabled: Bool {
120-
vpn.state == .connecting ||
121-
vpn.state == .disconnecting ||
122-
// Prevent starting the VPN before the user has approved the system extension.
123-
vpn.state == .failed(.systemExtensionError(.needsUserApproval)) ||
124-
// Prevent starting the VPN without a VPN configuration.
125-
vpn.state == .failed(.networkExtensionError(.unconfigured))
120+
// Always enabled if signed out, as that will open the sign in window
121+
state.hasSession && (
122+
vpn.state == .connecting ||
123+
vpn.state == .disconnecting ||
124+
// Prevent starting the VPN before the user has approved the system extension.
125+
vpn.state == .failed(.systemExtensionError(.needsUserApproval)) ||
126+
// Prevent starting the VPN without a VPN configuration.
127+
vpn.state == .failed(.networkExtensionError(.unconfigured))
128+
)
126129
}
127130
}
128131

Coder-Desktop/Coder-DesktopTests/VPNMenuTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ struct VPNMenuTests {
5959
@Test
6060
func testVPNDisabledWhileConnecting() async throws {
6161
vpn.state = .disabled
62+
state.login(baseAccessURL: URL(string: "https://coder.example.com")!, sessionToken: "fake-token")
6263

6364
try await ViewHosting.host(view) {
6465
try await sut.inspection.inspect { view in
@@ -79,6 +80,7 @@ struct VPNMenuTests {
7980
@Test
8081
func testVPNDisabledWhileDisconnecting() async throws {
8182
vpn.state = .disabled
83+
state.login(baseAccessURL: URL(string: "https://coder.example.com")!, sessionToken: "fake-token")
8284

8385
try await ViewHosting.host(view) {
8486
try await sut.inspection.inspect { view in

0 commit comments

Comments
 (0)