✨ Add logout() (POST /v1/logout) #39
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "feat/logout"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds
ComwattClient.logout()— a proper server-side logout, which the client was missing (onlyclose()existed, and it explicitly does not log out).POST /api/v1/logout— invalidates thecwt_sessioncookie server-side._username/_auth_hashsoauto_reauthcannot silently re-establish the session on the next request (without this, the first call afterlogout()would resurrect the session).401(already logged out) is treated as a successful no-op; only unexpected statuses raiseComwattAPIError.close()(which only releases the local HTTP session, no network call).Live verification (2026-07-05)
POST /api/v1/logout→200with empty body andSet-Cookie: cwt_session=; Expires=1970…(requests drops the cookie).GET /api/users/authenticatedthen returns401. A second logout returns401(hence the idempotent handling).Tests
test_logout_success— returnsNone, POSTs/v1/logout, clears credentials.test_logout_idempotent_when_already_logged_out—401is a no-op.test_logout_prevents_auto_reauth— after logout, a401is not silently re-authenticated.test_logout_keeps_credentials_on_unexpected_error— credentials preserved on500.89 tests pass, mypy clean.
Opened as draft (WIP) — mark ready for review when you want.
WIP: ✨ Add logout() (POST /v1/logout)to ✨ Add logout() (POST /v1/logout)