Skip to content

Commit

Permalink
Refactor getEmailVerifyLink
Browse files Browse the repository at this point in the history
  • Loading branch information
nkshah2 committed Oct 9, 2023
1 parent d896dc5 commit db21d5e
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/build/recipe/emailverification/api/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ function getAPIInterface() {
token: response.token,
recipeId: options.recipeId,
tenantId,
request: options.req,
userContext,
});
logger_1.logDebugMessage(`Sending email verification email to ${emailInfo}`);
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/emailverification/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const recipe_1 = __importDefault(require("./recipe"));
const error_1 = __importDefault(require("./error"));
const emailVerificationClaim_1 = require("./emailVerificationClaim");
const utils_1 = require("./utils");
const __1 = require("../..");
class Wrapper {
static async createEmailVerificationToken(tenantId, recipeUserId, email, userContext = {}) {
const recipeInstance = recipe_1.default.getInstanceOrThrowError();
Expand Down Expand Up @@ -67,6 +68,7 @@ class Wrapper {
token: emailVerificationToken.token,
recipeId: recipeInstance.getRecipeId(),
tenantId,
request: __1.getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down
2 changes: 2 additions & 0 deletions lib/build/recipe/emailverification/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 } from "./types";
import { NormalisedAppinfo } from "../../types";
import { BaseRequest } from "../../framework";
export declare function validateAndNormaliseUserInput(
_: Recipe,
appInfo: NormalisedAppinfo,
Expand All @@ -12,5 +13,6 @@ export declare function getEmailVerifyLink(input: {
token: string;
recipeId: string;
tenantId: string;
request: BaseRequest | undefined;
userContext: any;
}): string;
3 changes: 1 addition & 2 deletions lib/build/recipe/emailverification/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ var __importDefault =
Object.defineProperty(exports, "__esModule", { value: true });
exports.getEmailVerifyLink = exports.validateAndNormaliseUserInput = void 0;
const backwardCompatibility_1 = __importDefault(require("./emaildelivery/services/backwardCompatibility"));
const __1 = require("../..");
function validateAndNormaliseUserInput(_, appInfo, config) {
let override = Object.assign(
{
Expand Down Expand Up @@ -68,7 +67,7 @@ function getEmailVerifyLink(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/ts/recipe/emailverification/api/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ export default function getAPIInterface(): APIInterface {
token: response.token,
recipeId: options.recipeId,
tenantId,
request: options.req,
userContext,
});

Expand Down
2 changes: 2 additions & 0 deletions lib/ts/recipe/emailverification/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { EmailVerificationClaim } from "./emailVerificationClaim";
import RecipeUserId from "../../recipeUserId";
import { getEmailVerifyLink } from "./utils";
import { getRequestFromUserContext } from "../..";

export default class Wrapper {
static init = Recipe.init;
Expand Down Expand Up @@ -97,6 +98,7 @@ export default class Wrapper {
token: emailVerificationToken.token,
recipeId: recipeInstance.getRecipeId(),
tenantId,
request: getRequestFromUserContext(userContext),
userContext,
}),
};
Expand Down
5 changes: 3 additions & 2 deletions lib/ts/recipe/emailverification/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import Recipe from "./recipe";
import { TypeInput, TypeNormalisedInput, RecipeInterface, APIInterface } from "./types";
import { NormalisedAppinfo } from "../../types";
import BackwardCompatibilityService from "./emaildelivery/services/backwardCompatibility";
import { getRequestFromUserContext } from "../..";
import { BaseRequest } from "../../framework";

export function validateAndNormaliseUserInput(
_: Recipe,
Expand Down Expand Up @@ -69,12 +69,13 @@ export function getEmailVerifyLink(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

0 comments on commit db21d5e

Please sign in to comment.