Skip to content

Commit 10fa30e

Browse files
committed
Fix bug in userResolver that is related to return non-updated data for user
1 parent aaece02 commit 10fa30e

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/resolvers/userResolver.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,19 @@ export class UserResolver {
291291
emailConfirmationSentAt: new Date(),
292292
});
293293

294+
const updatedUser = await findUserById(userId);
295+
296+
if (!updatedUser) {
297+
throw new Error(i18n.__(translationErrorMessagesKeys.USER_NOT_FOUND));
298+
}
299+
294300
await getNotificationAdapter().sendUserEmailConfirmation({
295301
email,
296-
user: userToVerify,
302+
user: updatedUser,
297303
code,
298304
});
299305

300-
return userToVerify;
306+
return updatedUser;
301307
} catch (e) {
302308
logger.error('userVerificationSendEmailConfirmation() error', e);
303309
throw e;
@@ -356,7 +362,13 @@ export class UserResolver {
356362
emailConfirmationSentAt: null,
357363
});
358364

359-
return userFromDB;
365+
const updatedUser = await findUserById(userId);
366+
367+
if (!updatedUser) {
368+
throw new Error(i18n.__(translationErrorMessagesKeys.USER_NOT_FOUND));
369+
}
370+
371+
return updatedUser;
360372
} catch (e) {
361373
logger.error('userVerificationConfirmEmail() error', e);
362374
throw e;

0 commit comments

Comments
 (0)