From df934efb193f3f7edc6df797e745b7f0955527d5 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 5 Mar 2026 13:26:29 -0500 Subject: [PATCH] fix(submit): clear cached credentials on login failure Problem: bad credentials were saved to cache before validation, so subsequent `:CP submit` calls silently reused them instead of re-prompting the user. Solution: match `"Login failed"` in the submit error callback and call `cache.clear_credentials()` so the next attempt re-prompts. --- lua/cp/submit.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lua/cp/submit.lua b/lua/cp/submit.lua index d89d2a4..979c383 100644 --- a/lua/cp/submit.lua +++ b/lua/cp/submit.lua @@ -75,10 +75,11 @@ function M.submit(opts) if result and result.success then logger.log('Submitted successfully', { level = vim.log.levels.INFO, override = true }) else - logger.log( - 'Submit failed: ' .. (result and result.error or 'unknown error'), - { level = vim.log.levels.ERROR } - ) + local err = result and result.error or 'unknown error' + if err:match('^Login failed') then + cache.clear_credentials(platform) + end + logger.log('Submit failed: ' .. err, { level = vim.log.levels.ERROR }) end end) end