@@ -9,31 +9,31 @@ import { ssoTenantProduct } from "@calcom/features/ee/sso/lib/sso";
99import { checkUsername } from "@calcom/features/profile/lib/checkUsername" ;
1010import { OnboardingPathService } from "@calcom/features/onboarding/lib/onboarding-path.service" ;
1111import { IS_PREMIUM_USERNAME_ENABLED } from "@calcom/lib/constants" ;
12- import prisma from "@calcom/prisma" ;
12+ import { prisma } from "@calcom/prisma" ;
13+ import { z } from "zod" ;
1314
14- import { asStringOrNull } from "@lib/asStringOrNull" ;
15+ const Params = z . object ( {
16+ username : z . string ( ) . optional ( ) ,
17+ email : z . string ( ) . optional ( ) ,
18+ provider : z . string ( { required_error : "File is not named sso/[provider]" } ) ,
19+ } ) ;
1520
16- export const getServerSideProps = async ( context : GetServerSidePropsContext ) => {
17- // get query params and typecast them to string
18- // (would be even better to assert them instead of typecasting)
19- const providerParam = asStringOrNull ( context . query . provider ) ;
20- const emailParam = asStringOrNull ( context . query . email ) ;
21- const usernameParam = asStringOrNull ( context . query . username ) ;
21+ export const getServerSideProps = async ( { req, query } : GetServerSidePropsContext ) => {
22+
23+ const {
24+ provider : providerParam ,
25+ email : emailParam ,
26+ username : usernameParam ,
27+ } = Params . parse ( query ) ;
2228
2329 const successDestination = await OnboardingPathService . getGettingStartedPathWithParams (
2430 prisma ,
2531 usernameParam ? { username : usernameParam } : undefined
2632 ) ;
2733
28- if ( ! providerParam ) {
29- throw new Error ( `File is not named sso/[provider]` ) ;
30- }
31-
32- const { req } = context ;
33-
3434 const session = await getServerSession ( { req } ) ;
3535
36- const { currentOrgDomain } = orgDomainConfig ( context . req ) ;
36+ const { currentOrgDomain } = orgDomainConfig ( req ) ;
3737
3838 if ( session ) {
3939 // Validating if username is Premium, while this is true an email its required for stripe user confirmation
0 commit comments