chore: tech debt clearing - getServerSession has a dead arg: res (#19053)

* remove res from arg list in getServerSession

* remove res from all usages of getServerSession
This commit is contained in:
Benny Joo authored and GitHub committed 2025-02-03 00:12:42 -05:00
1 parent 15d6839985
commit f0dc3bba17
29 files changed
+42 -45

No files matched your search

@@ -11,8 +11,8 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
if (typeof ctx.params?.slug !== "string") return notFound;
const { req, res } = ctx;
const session = await getServerSession({ req, res });
const { req } = ctx;
const session = await getServerSession({ req });
if (!session?.user?.id) {
const redirect = { redirect: { permanent: false, destination: "/auth/login" } } as const;
@@ -11,8 +11,8 @@ export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
if (typeof ctx.params?.slug !== "string") return notFound;
const { req, res } = ctx;
const session = await getServerSession({ req, res });
const { req } = ctx;
const session = await getServerSession({ req });
if (!session?.user?.id) {
const redirect = { redirect: { permanent: false, destination: "/auth/login" } } as const;
@@ -8,7 +8,7 @@ import { decodeOAuthState } from "../../_utils/oauth/decodeOAuthState";
import { storeHuddle01Credential } from "../utils/storage";
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
const state = decodeOAuthState(req);
+1 -1
View File
@@ -14,7 +14,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
if (typeof appKeys.client_id === "string") client_id = appKeys.client_id;
if (!client_id) return res.status(400).json({ message: "pipedrive client id missing." });
// Check that user is authenticated
req.session = await getServerSession({ req, res });
req.session = await getServerSession({ req });
const { teamId } = req.query;
const user = req.session?.user;
if (!user) {
@@ -1,5 +1,5 @@
import { LRUCache } from "lru-cache";
import type { GetServerSidePropsContext, NextApiRequest, NextApiResponse } from "next";
import type { GetServerSidePropsContext, NextApiRequest } from "next";
import type { AuthOptions, Session } from "next-auth";
import { getToken } from "next-auth/jwt";
@@ -30,7 +30,6 @@ const CACHE = new LRUCache<string, Session>({ max: 1000 });
*/
export async function getServerSession(options: {
req: NextApiRequest | GetServerSidePropsContext["req"];
res?: NextApiResponse | GetServerSidePropsContext["res"];
authOptions?: AuthOptions;
}) {
const { req, authOptions: { secret } = {} } = options;
@@ -4,7 +4,7 @@ import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
import { getFeatureFlag } from "@calcom/features/flags/server/utils";
import { MembershipRole } from "@calcom/prisma/client";
export const getServerSideProps = async ({ req, res }: GetServerSidePropsContext) => {
export const getServerSideProps = async ({ req }: GetServerSidePropsContext) => {
const prisma = await import("@calcom/prisma").then((mod) => mod.default);
const organizationsEnabled = await getFeatureFlag(prisma, "organizations");
// Check if organizations are enabled
@@ -15,7 +15,7 @@ export const getServerSideProps = async ({ req, res }: GetServerSidePropsContext
}
// Check if logged in user has an organization assigned
const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
if (!session?.user.profile?.organizationId) {
return {
@@ -7,9 +7,8 @@ export type PageProps = inferSSRProps<typeof getServerSidePropsForMembers>;
export const getServerSidePropsForMembers = async function getServerSidePropsForMembers({
req,
res,
}: GetServerSidePropsContext) {
const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
if (!session || !session.user) {
return {
+1 -1
View File
@@ -72,7 +72,7 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
if (!metadata.success) throw new HttpError({ statusCode: 400, message: "Invalid team metadata" });
}
const session = await getServerSession({ req, res });
const session = await getServerSession({ req });
if (!session) return { message: "Team upgraded successfully" };
@@ -85,9 +85,9 @@ export async function getUserFromSession(ctx: TRPCContextInner, session: Maybe<S
export type UserFromSession = Awaited<ReturnType<typeof getUserFromSession>>;
const getSession = async (ctx: TRPCContextInner) => {
const { req, res } = ctx;
const { req } = ctx;
const { getServerSession } = await import("@calcom/features/auth/lib/getServerSession");
return req ? await getServerSession({ req, res }) : null;
return req ? await getServerSession({ req }) : null;
};
export const getUserSession = async (ctx: TRPCContextInner) => {