diff --git a/packages/core/types/src/common/config-module.ts b/packages/core/types/src/common/config-module.ts index c29ddba886..e90bc1e617 100644 --- a/packages/core/types/src/common/config-module.ts +++ b/packages/core/types/src/common/config-module.ts @@ -735,7 +735,7 @@ export type ProjectConfigOptions = { * } * ``` */ - authMethodsPerActor: Record + authMethodsPerActor?: Record } } diff --git a/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/callback/route.ts b/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/callback/route.ts index a24d1c91bc..f6bb2e9372 100644 --- a/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/callback/route.ts +++ b/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/callback/route.ts @@ -14,10 +14,11 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => { ContainerRegistrationKeys.CONFIG_MODULE ) - const authMethods = (config.projectConfig?.http as any)?.authMethods ?? {} + const authMethodsPerActor = + config.projectConfig?.http?.authMethodsPerActor ?? {} // Not having the config defined would allow for all auth providers for the particular actor. - if (authMethods[actor_type]) { - if (!authMethods[actor_type].includes(auth_provider)) { + if (authMethodsPerActor[actor_type]) { + if (!authMethodsPerActor[actor_type].includes(auth_provider)) { throw new MedusaError( MedusaError.Types.NOT_ALLOWED, `The actor type ${actor_type} is not allowed to use the auth provider ${auth_provider}` diff --git a/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/route.ts b/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/route.ts index 50590d77ae..9bb8b6b681 100644 --- a/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/route.ts +++ b/packages/medusa/src/api/auth/[actor_type]/[auth_provider]/route.ts @@ -14,10 +14,11 @@ export const GET = async (req: MedusaRequest, res: MedusaResponse) => { ContainerRegistrationKeys.CONFIG_MODULE ) - const authMethods = (config.projectConfig?.http as any)?.authMethods ?? {} + const authMethodsPerActor = + config.projectConfig?.http?.authMethodsPerActor ?? {} // Not having the config defined would allow for all auth providers for the particular actor. - if (authMethods[actor_type]) { - if (!authMethods[actor_type].includes(auth_provider)) { + if (authMethodsPerActor[actor_type]) { + if (!authMethodsPerActor[actor_type].includes(auth_provider)) { throw new MedusaError( MedusaError.Types.NOT_ALLOWED, `The actor type ${actor_type} is not allowed to use the auth provider ${auth_provider}`