Skip to content

Commit

Permalink
refactors an exception case
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Aug 7, 2024
1 parent 2366db6 commit d80ca83
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
3 changes: 3 additions & 0 deletions lib/build/recipe/accountlinking/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class Wrapper {
}
static async isEmailChangeAllowed(recipeUserId, newEmail, isVerified, session, userContext) {
const user = await __1.getUser(recipeUserId.getAsString(), userContext);
if (user === undefined) {
throw new Error("Passed in recipe user id does not exist");
}
const res = await recipe_1.default.getInstance().isEmailChangeAllowed({
user,
newEmail,
Expand Down
2 changes: 1 addition & 1 deletion lib/build/recipe/accountlinking/recipe.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default class Recipe extends RecipeModule {
userContext: UserContext;
}) => Promise<boolean>;
isEmailChangeAllowed: (input: {
user?: User;
user: User;
newEmail: string;
isVerified: boolean;
session: SessionContainerInterface | undefined;
Expand Down
3 changes: 0 additions & 3 deletions lib/build/recipe/accountlinking/recipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,6 @@ class Recipe extends recipeModule_1.default {
* in account take over if this recipe user is malicious.
*/
let inputUser = input.user;
if (inputUser === undefined) {
throw new Error("Passed in recipe user id does not exist");
}
for (const tenantId of inputUser.tenantIds) {
let existingUsersWithNewEmail = await this.recipeInterfaceImpl.listUsersByAccountInfo({
tenantId,
Expand Down
4 changes: 4 additions & 0 deletions lib/ts/recipe/accountlinking/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ export default class Wrapper {
) {
const user = await getUser(recipeUserId.getAsString(), userContext);

if (user === undefined) {
throw new Error("Passed in recipe user id does not exist");
}

const res = await Recipe.getInstance().isEmailChangeAllowed({
user,
newEmail,
Expand Down
6 changes: 1 addition & 5 deletions lib/ts/recipe/accountlinking/recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ export default class Recipe extends RecipeModule {
};

isEmailChangeAllowed = async (input: {
user?: User;
user: User;
newEmail: string;
isVerified: boolean;
session: SessionContainerInterface | undefined;
Expand All @@ -546,10 +546,6 @@ export default class Recipe extends RecipeModule {

let inputUser = input.user;

if (inputUser === undefined) {
throw new Error("Passed in recipe user id does not exist");
}

for (const tenantId of inputUser.tenantIds) {
let existingUsersWithNewEmail = await this.recipeInterfaceImpl.listUsersByAccountInfo({
tenantId,
Expand Down

0 comments on commit d80ca83

Please sign in to comment.