Skip to content

Commit

Permalink
fix(multi-tenant): fix change password issue (#372)
Browse files Browse the repository at this point in the history
  • Loading branch information
dipendraupreti committed May 11, 2023
1 parent 57bc5bb commit 41154df
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -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 = (
Expand All @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 2 additions & 1 deletion packages/user/src/model/users/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ class UserService<
const isPasswordValid =
await ThirdPartyEmailPassword.emailPasswordSignIn(
userInfo.email,
oldPassword
oldPassword,
{ dbSchema: this.schema }
);

if (isPasswordValid.status === "OK") {
Expand Down

0 comments on commit 41154df

Please sign in to comment.