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.
This commit is contained in:
Barrett Ruth 2026-03-05 13:26:29 -05:00
parent 86b3eb9582
commit df934efb19
Signed by: barrett
GPG key ID: A6C96C9349D2FC81

View file

@ -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