fix: Users details leak for team booking when the team is private (#17403)

* fix: host details leaking

* type error

* update

* update

* Update getPublicEvent.ts

* Update getPublicEvent.ts
This commit is contained in:
Anik Dhabal Babu authored and GitHub committed 2024-11-11 19:55:42 +05:30
1 parent 30f9d9b980
commit ae9063804d
5 files changed
+36 -8

No files matched your search

@@ -147,7 +147,7 @@ const getSession = async (ctx: TRPCContextInner) => {
return req ? await getServerSession({ req, res }) : null;
};
const getUserSession = async (ctx: TRPCContextInner) => {
export const getUserSession = async (ctx: TRPCContextInner) => {
/**
* It is possible that the session and user have already been added to the context by a previous middleware
* or when creating the context
@@ -4,10 +4,11 @@ import type { TEventInputSchema } from "./event.schema";
interface EventHandlerOptions {
input: TEventInputSchema;
userId?: number;
}
export const eventHandler = async ({ input }: EventHandlerOptions) => {
return await EventRepository.getPublicEvent(input);
export const eventHandler = async ({ input, userId }: EventHandlerOptions) => {
return await EventRepository.getPublicEvent(input, userId);
};
export default eventHandler;
@@ -1,3 +1,4 @@
import { getUserSession } from "../../../middlewares/sessionMiddleware";
import publicProcedure from "../../../procedures/publicProcedure";
import { importHandler } from "../../../trpc";
import { ZEventInputSchema } from "../event.schema";
@@ -6,6 +7,7 @@ const NAMESPACE = "publicViewer";
const namespaced = (s: string) => `${NAMESPACE}.${s}`;
export const event = publicProcedure.input(ZEventInputSchema).query(async (opts) => {
const { user } = await getUserSession(opts.ctx);
const handler = await importHandler(namespaced("event"), () => import("../event.handler"));
return handler(opts);
return handler({ input: opts.input, userId: user?.id });
});