mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-15 04:18:19 +00:00
fix(gitlab): sanitize PAT auth failures across cli and web
This commit is contained in:
1 parent
4e738ee021
commit
7f1c23607d
4 files changed
+171
-21
No files matched your search
@@ -56,6 +56,7 @@ import {
|
||||
} from './token-manager';
|
||||
import { executeOAuthProcess } from './oauth-process';
|
||||
import { importKiroToken } from './kiro-import';
|
||||
import { parseGitLabPatAuthResponse } from './gitlab-pat-response';
|
||||
import {
|
||||
getProxyTarget,
|
||||
buildProxyUrl,
|
||||
@@ -723,22 +724,16 @@ async function handleGitLabPatLogin(
|
||||
}),
|
||||
});
|
||||
|
||||
const responseBody = (await response.text()).trim();
|
||||
let payload: Record<string, unknown> = {};
|
||||
if (responseBody) {
|
||||
try {
|
||||
payload = JSON.parse(responseBody) as Record<string, unknown>;
|
||||
} catch {
|
||||
payload = { error: responseBody };
|
||||
}
|
||||
}
|
||||
const responseBody = await response.text();
|
||||
const parsedResponse = parseGitLabPatAuthResponse(
|
||||
response.ok,
|
||||
response.status,
|
||||
responseBody,
|
||||
token
|
||||
);
|
||||
|
||||
if (!response.ok || payload.status !== 'ok') {
|
||||
const errorMessage =
|
||||
(typeof payload.error === 'string' && payload.error) ||
|
||||
responseBody ||
|
||||
`GitLab PAT login failed with status ${response.status}`;
|
||||
console.log(fail(errorMessage));
|
||||
if (!parsedResponse.ok) {
|
||||
console.log(fail(parsedResponse.errorMessage));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user