fix: strip credentials from gitProvider.getAll API response (#4569)

* fix: strip credentials from gitProvider.getAll API response

* [autofix.ci] apply automated fixes

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Mauricio Siu
2026-06-07 01:29:04 -06:00
committed by GitHub
parent dfbae18557
commit 6b68fcab8c
2 changed files with 65 additions and 30 deletions

View File

@@ -134,15 +134,10 @@ export const ShowGitProviders = () => {
const canManage = gitProvider.isOwner || isOrgAdmin; const canManage = gitProvider.isOwner || isOrgAdmin;
const haveGithubRequirements = const haveGithubRequirements =
isGithub && isGithub && gitProvider.github?.isConfigured;
gitProvider.github?.githubPrivateKey &&
gitProvider.github?.githubAppId &&
gitProvider.github?.githubInstallationId;
const haveGitlabRequirements = const haveGitlabRequirements =
isGitlab && isGitlab && gitProvider.gitlab?.isConfigured;
gitProvider.gitlab?.accessToken &&
gitProvider.gitlab?.refreshToken;
return ( return (
<div <div
@@ -230,8 +225,7 @@ export const ShowGitProviders = () => {
)} )}
{isBitbucket && {isBitbucket &&
gitProvider.bitbucket?.appPassword && gitProvider.bitbucket?.isDeprecated ? (
!gitProvider.bitbucket?.apiToken ? (
<Badge variant="yellow">Deprecated</Badge> <Badge variant="yellow">Deprecated</Badge>
) : null} ) : null}
@@ -244,7 +238,7 @@ export const ShowGitProviders = () => {
Action Required Action Required
</Badge> </Badge>
<Link <Link
href={`${gitProvider?.github?.githubAppName}/installations/new?state=gh_setup:${gitProvider?.github.githubId}`} href={`${gitProvider?.github?.githubAppName}/installations/new?state=gh_setup:${gitProvider?.github?.githubId}`}
className={buttonVariants({ className={buttonVariants({
size: "icon", size: "icon",
variant: "ghost", variant: "ghost",
@@ -280,7 +274,7 @@ export const ShowGitProviders = () => {
href={getGitlabUrl( href={getGitlabUrl(
gitProvider.gitlab?.applicationId || "", gitProvider.gitlab?.applicationId || "",
gitProvider.gitlab?.gitlabId || "", gitProvider.gitlab?.gitlabId || "",
gitProvider.gitlab?.gitlabUrl, gitProvider.gitlab?.gitlabUrl || "",
)} )}
target="_blank" target="_blank"
className={buttonVariants({ className={buttonVariants({
@@ -295,29 +289,33 @@ export const ShowGitProviders = () => {
{canManage && ( {canManage && (
<> <>
{isGithub && haveGithubRequirements && ( {isGithub &&
<EditGithubProvider haveGithubRequirements &&
githubId={gitProvider.github?.githubId} gitProvider.github?.githubId && (
/> <EditGithubProvider
)} githubId={gitProvider.github.githubId}
/>
)}
{isGitlab && ( {isGitlab &&
<EditGitlabProvider gitProvider.gitlab?.gitlabId && (
gitlabId={gitProvider.gitlab?.gitlabId} <EditGitlabProvider
/> gitlabId={gitProvider.gitlab.gitlabId}
)} />
)}
{isBitbucket && ( {isBitbucket &&
<EditBitbucketProvider gitProvider.bitbucket?.bitbucketId && (
bitbucketId={ <EditBitbucketProvider
gitProvider.bitbucket?.bitbucketId bitbucketId={
} gitProvider.bitbucket.bitbucketId
/> }
)} />
)}
{isGitea && ( {isGitea && gitProvider.gitea?.giteaId && (
<EditGiteaProvider <EditGiteaProvider
giteaId={gitProvider.gitea?.giteaId} giteaId={gitProvider.gitea.giteaId}
/> />
)} )}

View File

@@ -42,6 +42,43 @@ export const gitProviderRouter = createTRPCRouter({
return results.map((r) => ({ return results.map((r) => ({
...r, ...r,
isOwner: r.userId === ctx.session.userId, isOwner: r.userId === ctx.session.userId,
github: r.github
? {
githubId: r.github.githubId,
githubAppName: r.github.githubAppName,
githubAppId: r.github.githubAppId,
githubInstallationId: r.github.githubInstallationId,
isConfigured: !!(
r.github.githubPrivateKey &&
r.github.githubAppId &&
r.github.githubInstallationId
),
}
: null,
gitlab: r.gitlab
? {
gitlabId: r.gitlab.gitlabId,
applicationId: r.gitlab.applicationId,
gitlabUrl: r.gitlab.gitlabUrl,
isConfigured: !!(r.gitlab.accessToken && r.gitlab.refreshToken),
}
: null,
bitbucket: r.bitbucket
? {
bitbucketId: r.bitbucket.bitbucketId,
bitbucketUsername: r.bitbucket.bitbucketUsername,
isConfigured: false,
isDeprecated: !!(r.bitbucket.appPassword && !r.bitbucket.apiToken),
}
: null,
gitea: r.gitea
? {
giteaId: r.gitea.giteaId,
giteaUrl: r.gitea.giteaUrl,
clientId: r.gitea.clientId,
isConfigured: !!(r.gitea.accessToken && r.gitea.refreshToken),
}
: null,
})); }));
}), }),