Skip to content

Commit

Permalink
Fix bug in userResolver that is related to return non-updated data fo…
Browse files Browse the repository at this point in the history
…r user
  • Loading branch information
ae2079 committed Aug 19, 2024
1 parent aaece02 commit 10fa30e
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/resolvers/userResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,19 @@ export class UserResolver {
emailConfirmationSentAt: new Date(),
});

const updatedUser = await findUserById(userId);

if (!updatedUser) {
throw new Error(i18n.__(translationErrorMessagesKeys.USER_NOT_FOUND));
}

await getNotificationAdapter().sendUserEmailConfirmation({
email,
user: userToVerify,
user: updatedUser,
code,
});

return userToVerify;
return updatedUser;
} catch (e) {
logger.error('userVerificationSendEmailConfirmation() error', e);
throw e;
Expand Down Expand Up @@ -356,7 +362,13 @@ export class UserResolver {
emailConfirmationSentAt: null,
});

return userFromDB;
const updatedUser = await findUserById(userId);

if (!updatedUser) {
throw new Error(i18n.__(translationErrorMessagesKeys.USER_NOT_FOUND));
}

return updatedUser;
} catch (e) {
logger.error('userVerificationConfirmEmail() error', e);
throw e;
Expand Down

0 comments on commit 10fa30e

Please sign in to comment.