fix: saml update/delete only owner team (#2948)
Co-authored-by: Agusti Fernandez Pardo <git@agusti.me> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/2978/head
parent
eb6e092a21
commit
456ba9db04
|
@ -14,6 +14,7 @@ import { checkRegularUsername } from "@lib/core/checkRegularUsername";
|
|||
import { sendFeedbackEmail } from "@lib/emails/email-manager";
|
||||
import jackson from "@lib/jackson";
|
||||
import prisma from "@lib/prisma";
|
||||
import { isTeamOwner } from "@lib/queries/teams";
|
||||
import {
|
||||
hostedCal,
|
||||
isSAMLAdmin,
|
||||
|
@ -860,9 +861,9 @@ const loggedInViewerRouter = createProtectedRouter()
|
|||
encodedRawMetadata: z.string(),
|
||||
teamId: z.union([z.number(), z.null(), z.undefined()]),
|
||||
}),
|
||||
async resolve({ input }) {
|
||||
async resolve({ ctx, input }) {
|
||||
const { encodedRawMetadata, teamId } = input;
|
||||
|
||||
if (teamId && !(await isTeamOwner(ctx.user?.id, teamId))) throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
const { apiController } = await jackson();
|
||||
|
||||
try {
|
||||
|
@ -883,8 +884,9 @@ const loggedInViewerRouter = createProtectedRouter()
|
|||
input: z.object({
|
||||
teamId: z.union([z.number(), z.null(), z.undefined()]),
|
||||
}),
|
||||
async resolve({ input }) {
|
||||
async resolve({ ctx, input }) {
|
||||
const { teamId } = input;
|
||||
if (teamId && !(await isTeamOwner(ctx.user?.id, teamId))) throw new TRPCError({ code: "UNAUTHORIZED" });
|
||||
|
||||
const { apiController } = await jackson();
|
||||
|
||||
|
|
Loading…
Reference in New Issue