Skip to content

Scheduling infrastructure for absolutely everyone.

fix: SAML: invalid_code issue, missing user error signing up (#15522)

Alex van Andeldbf4be27ea59
diff --git a/apps/web/pages/auth/saml-idp.tsx b/apps/web/pages/auth/saml-idp.tsx
index 6942574a60e..661980fa686 100644
--- a/apps/web/pages/auth/saml-idp.tsx
+++ b/apps/web/pages/auth/saml-idp.tsx
@@ -3,8 +3,6 @@ import { useEffect } from "react";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
-import PageWrapper from "@components/PageWrapper";
-
// To handle the IdP initiated login flow callback
export default function Page() {
const searchParams = useCompatSearchParams();
@@ -21,4 +19,3 @@ export default function Page() {
return null;
}
-Page.PageWrapper = PageWrapper;
diff --git a/packages/app-store/_utils/installation.ts b/packages/app-store/_utils/installation.ts
index 716d0c9c475..16d45bed7ff 100644
--- a/packages/app-store/_utils/installation.ts
+++ b/packages/app-store/_utils/installation.ts
@@ -20,7 +20,7 @@ type InstallationArgs = {
appType: string;
user: {
id: number;
- profile: UserProfile;
+ profile?: UserProfile;
};
slug: string;
key?: Prisma.InputJsonValue;
diff --git a/packages/features/auth/lib/next-auth-options.ts b/packages/features/auth/lib/next-auth-options.ts
index a0bf241de0f..f5a12f2cb9c 100644
--- a/packages/features/auth/lib/next-auth-options.ts
+++ b/packages/features/auth/lib/next-auth-options.ts
@@ -281,9 +281,6 @@ if (isSAMLLoginEnabled) {
const user = await UserRepository.findByEmailAndIncludeProfilesAndPassword({
email: profile.email || "",
});
- if (!user) throw new Error(ErrorCode.UserNotFound);
-
- const [userProfile] = user.allProfiles;
return {
id: profile.id || 0,
firstName: profile.firstName || "",
@@ -292,7 +289,7 @@ if (isSAMLLoginEnabled) {
name: `${profile.firstName || ""} ${profile.lastName || ""}`.trim(),
email_verified: true,
locale: profile.locale,
- profile: userProfile,
+ ...(user ? { profile: user.allProfiles[0] } : {}),
};
},
options: {
diff --git a/packages/features/ee/organizations/pages/organization.tsx b/packages/features/ee/organizations/pages/organization.tsx
index 16a65e377ec..954cba42f37 100644
--- a/packages/features/ee/organizations/pages/organization.tsx
+++ b/packages/features/ee/organizations/pages/organization.tsx
@@ -17,7 +17,7 @@ export const getServerSideProps = async ({ req, res }: GetServerSidePropsContext
// Check if logged in user has an organization assigned
const session = await getServerSession({ req, res });
- if (!session?.user.profile.organizationId) {
+ if (!session?.user.profile?.organizationId) {
return {
notFound: true,
};
diff --git a/packages/types/next-auth.d.ts b/packages/types/next-auth.d.ts
index 438c2fa7da5..fadae41d4ac 100644
--- a/packages/types/next-auth.d.ts
+++ b/packages/types/next-auth.d.ts
@@ -38,7 +38,7 @@ declare module "next-auth" {
avatarUrl?: PrismaUser["avatarUrl"];
role?: PrismaUser["role"] | "INACTIVE_ADMIN";
locale?: string | null;
- profile: UserProfile;
+ profile?: UserProfile;
}
}