Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: invalidate cached token on disconnect so reconnect can rekey

When a garden is disconnected (e.g. server rejected auth because the
OAuth client was deleted), the cached access token is invalidated.
This forces the next reconnect to go through reauthenticate → rekey
instead of reusing a token the server will reject again.

sow-157

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

+16 -2
+16 -2
apps/garden/lib/garden/socket.ex
··· 128 128 end 129 129 130 130 @impl Slipstream 131 - def handle_disconnect(_reason, socket) do 132 - Logger.warning(msg: "Disconnected from server socket") 131 + def handle_disconnect(reason, socket) do 132 + Logger.warning(msg: "Disconnected from server socket", reason: inspect(reason)) 133 + invalidate_cached_token() 133 134 {:ok, schedule_reconnect(socket)} 135 + end 136 + 137 + defp invalidate_cached_token do 138 + storage = Storage.read() 139 + 140 + case storage do 141 + %{oauth_credentials: %{access_token: _} = creds} -> 142 + updated_creds = Map.drop(creds, [:access_token, :token_issued_at, :expires_in]) 143 + storage |> Map.put(:oauth_credentials, updated_creds) |> Storage.write() 144 + 145 + _ -> 146 + :ok 147 + end 134 148 end 135 149 136 150 defp schedule_reconnect(socket) do