mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-07-25 15:55:43 +02:00
fix(types): guard git-provider access check for optional id in getBranches
The getBranches inputs type the provider id as optional, so only fetch and authorize when an id is actually present; the underlying getBranches already returns [] when no id is supplied.
This commit is contained in:
@@ -89,8 +89,10 @@ export const bitbucketRouter = createTRPCRouter({
|
|||||||
getBitbucketBranches: protectedProcedure
|
getBitbucketBranches: protectedProcedure
|
||||||
.input(apiFindBitbucketBranches)
|
.input(apiFindBitbucketBranches)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const bitbucket = await findBitbucketById(input.bitbucketId);
|
if (input.bitbucketId) {
|
||||||
await assertGitProviderAccess(ctx.session, bitbucket.gitProvider);
|
const bitbucket = await findBitbucketById(input.bitbucketId);
|
||||||
|
await assertGitProviderAccess(ctx.session, bitbucket.gitProvider);
|
||||||
|
}
|
||||||
return await getBitbucketBranches(input);
|
return await getBitbucketBranches(input);
|
||||||
}),
|
}),
|
||||||
testConnection: protectedProcedure
|
testConnection: protectedProcedure
|
||||||
|
|||||||
@@ -40,8 +40,10 @@ export const githubRouter = createTRPCRouter({
|
|||||||
getGithubBranches: protectedProcedure
|
getGithubBranches: protectedProcedure
|
||||||
.input(apiFindGithubBranches)
|
.input(apiFindGithubBranches)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const github = await findGithubById(input.githubId);
|
if (input.githubId) {
|
||||||
await assertGitProviderAccess(ctx.session, github.gitProvider);
|
const github = await findGithubById(input.githubId);
|
||||||
|
await assertGitProviderAccess(ctx.session, github.gitProvider);
|
||||||
|
}
|
||||||
return await getGithubBranches(input);
|
return await getGithubBranches(input);
|
||||||
}),
|
}),
|
||||||
githubProviders: protectedProcedure.query(async ({ ctx }) => {
|
githubProviders: protectedProcedure.query(async ({ ctx }) => {
|
||||||
|
|||||||
@@ -100,8 +100,10 @@ export const gitlabRouter = createTRPCRouter({
|
|||||||
getGitlabBranches: protectedProcedure
|
getGitlabBranches: protectedProcedure
|
||||||
.input(apiFindGitlabBranches)
|
.input(apiFindGitlabBranches)
|
||||||
.query(async ({ input, ctx }) => {
|
.query(async ({ input, ctx }) => {
|
||||||
const gitlab = await findGitlabById(input.gitlabId);
|
if (input.gitlabId) {
|
||||||
await assertGitProviderAccess(ctx.session, gitlab.gitProvider);
|
const gitlab = await findGitlabById(input.gitlabId);
|
||||||
|
await assertGitProviderAccess(ctx.session, gitlab.gitProvider);
|
||||||
|
}
|
||||||
return await getGitlabBranches(input);
|
return await getGitlabBranches(input);
|
||||||
}),
|
}),
|
||||||
testConnection: protectedProcedure
|
testConnection: protectedProcedure
|
||||||
|
|||||||
Reference in New Issue
Block a user