diff --git a/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignIn.ts b/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignIn.ts index 754c05fdc..3225f59ab 100644 --- a/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignIn.ts +++ b/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignIn.ts @@ -1,10 +1,15 @@ -import { formatDate } from "@dzangolab/fastify-user"; +import { UserService, formatDate } from "@dzangolab/fastify-user"; -import getUserService from "../../../lib/getUserService"; import Email from "../../utils/email"; -import type { AuthUser } from "@dzangolab/fastify-user"; +import type { + AuthUser, + User, + UserCreateInput, + UserUpdateInput, +} from "@dzangolab/fastify-user"; import type { FastifyInstance } from "fastify"; +import type { QueryResultRow } from "slonik"; import type { RecipeInterface } from "supertokens-node/recipe/thirdpartyemailpassword"; const emailPasswordSignIn = ( @@ -28,11 +33,11 @@ const emailPasswordSignIn = ( return originalResponse; } - const userService = getUserService( - config, - slonik, - input.userContext.tenant - ); + const userService = new UserService< + User & QueryResultRow, + UserCreateInput, + UserUpdateInput + >(config, slonik, input.userContext.dbSchema); const user = await userService.findById(originalResponse.user.id); diff --git a/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignInPost.ts b/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignInPost.ts index 8ab65a5ee..a5666b0be 100644 --- a/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignInPost.ts +++ b/packages/multi-tenant/src/supertokens/recipes/third-party-email-password/emailPasswordSignInPost.ts @@ -8,6 +8,7 @@ const emailPasswordSignInPOST = ( ): APIInterface["emailPasswordSignInPOST"] => { return async (input) => { input.userContext.tenant = input.options.req.original.tenant; + input.userContext.dbSchema = input.options.req.original.dbSchema; if (originalImplementation.emailPasswordSignInPOST === undefined) { throw new Error("Should never come here"); diff --git a/packages/user/src/model/users/service.ts b/packages/user/src/model/users/service.ts index 08a551902..d8554dd98 100644 --- a/packages/user/src/model/users/service.ts +++ b/packages/user/src/model/users/service.ts @@ -62,7 +62,8 @@ class UserService< const isPasswordValid = await ThirdPartyEmailPassword.emailPasswordSignIn( userInfo.email, - oldPassword + oldPassword, + { dbSchema: this.schema } ); if (isPasswordValid.status === "OK") {