Skip to content

Commit

Permalink
Refactor getPasswordResetLink
Browse files Browse the repository at this point in the history
  • Loading branch information
nkshah2 committed Oct 9, 2023
1 parent db21d5e commit 814d865
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions lib/build/recipe/emailpassword/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function getAPIImplementation() {
token: response.token,
recipeId: options.recipeId,
tenantId,
request: options.req,
userContext,
});
logger_1.logDebugMessage(`Sending password reset email to ${email}`);
Expand Down
1 change: 1 addition & 0 deletions lib/build/recipe/emailpassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class Wrapper {
recipeId: recipeInstance.getRecipeId(),
token: token.token,
tenantId: tenantId === undefined ? constants_1.DEFAULT_TENANT_ID : tenantId,
request: __1.getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/emailpassword/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import Recipe from "./recipe";
import { TypeInput, TypeNormalisedInput, NormalisedFormField, TypeInputFormField } from "./types";
import { NormalisedAppinfo } from "../../types";
import { BaseRequest } from "../../framework";
export declare function validateAndNormaliseUserInput(
recipeInstance: Recipe,
appInfo: NormalisedAppinfo,
Expand All @@ -26,5 +27,6 @@ export declare function getPasswordResetLink(input: {
token: string;
recipeId: string;
tenantId: string;
request: BaseRequest | undefined;
userContext: any;
}): string;
3 changes: 1 addition & 2 deletions lib/build/recipe/emailpassword/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.getPasswordResetLink = exports.defaultEmailValidator = exports.defaultPasswordValidator = exports.normaliseSignUpFormFields = exports.validateAndNormaliseUserInput = void 0;
const constants_1 = require("./constants");
const backwardCompatibility_1 = __importDefault(require("./emaildelivery/services/backwardCompatibility"));
const __1 = require("../..");
function validateAndNormaliseUserInput(recipeInstance, appInfo, config) {
let signUpFeature = validateAndNormaliseSignupConfig(
recipeInstance,
Expand Down Expand Up @@ -216,7 +215,7 @@ function getPasswordResetLink(input) {
return (
input.appInfo
.getOrigin({
request: __1.getRequestFromUserContext(input.userContext),
request: input.request,
userContext: input.userContext,
})
.getAsStringDangerous() +
Expand Down
1 change: 1 addition & 0 deletions lib/build/recipe/thirdpartyemailpassword/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ class Wrapper {
recipeId: recipeInstance.getRecipeId(),
token: token.token,
tenantId,
request: __1.getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down
1 change: 1 addition & 0 deletions lib/ts/recipe/emailpassword/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default function getAPIImplementation(): APIInterface {
token: response.token,
recipeId: options.recipeId,
tenantId,
request: options.req,
userContext,
});

Expand Down
3 changes: 2 additions & 1 deletion lib/ts/recipe/emailpassword/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RecipeInterface, APIOptions, APIInterface, TypeEmailPasswordEmailDelive
import RecipeUserId from "../../recipeUserId";
import { DEFAULT_TENANT_ID } from "../multitenancy/constants";
import { getPasswordResetLink } from "./utils";
import { getUser } from "../..";
import { getRequestFromUserContext, getUser } from "../..";

export default class Wrapper {
static init = Recipe.init;
Expand Down Expand Up @@ -123,6 +123,7 @@ export default class Wrapper {
recipeId: recipeInstance.getRecipeId(),
token: token.token,
tenantId: tenantId === undefined ? DEFAULT_TENANT_ID : tenantId,
request: getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down
5 changes: 3 additions & 2 deletions lib/ts/recipe/emailpassword/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { NormalisedAppinfo } from "../../types";
import { FORM_FIELD_EMAIL_ID, FORM_FIELD_PASSWORD_ID } from "./constants";
import { RecipeInterface, APIInterface } from "./types";
import BackwardCompatibilityService from "./emaildelivery/services/backwardCompatibility";
import { getRequestFromUserContext } from "../..";
import { BaseRequest } from "../../framework";

export function validateAndNormaliseUserInput(
recipeInstance: Recipe,
Expand Down Expand Up @@ -254,12 +254,13 @@ export function getPasswordResetLink(input: {
token: string;
recipeId: string;
tenantId: string;
request: BaseRequest | undefined;
userContext: any;
}): string {
return (
input.appInfo
.getOrigin({
request: getRequestFromUserContext(input.userContext),
request: input.request,
userContext: input.userContext,
})
.getAsStringDangerous() +
Expand Down
3 changes: 2 additions & 1 deletion lib/ts/recipe/thirdpartyemailpassword/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { TypeEmailPasswordEmailDeliveryInput } from "../emailpassword/types";
import RecipeUserId from "../../recipeUserId";
import { DEFAULT_TENANT_ID } from "../multitenancy/constants";
import { getPasswordResetLink } from "../emailpassword/utils";
import { getUser } from "../..";
import { getRequestFromUserContext, getUser } from "../..";

export default class Wrapper {
static init = Recipe.init;
Expand Down Expand Up @@ -146,6 +146,7 @@ export default class Wrapper {
recipeId: recipeInstance.getRecipeId(),
token: token.token,
tenantId,
request: getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down

0 comments on commit 814d865

Please sign in to comment.