diff --git a/src/entities/user.ts b/src/entities/user.ts index 04e787622..0a0d3e17b 100644 --- a/src/entities/user.ts +++ b/src/entities/user.ts @@ -210,7 +210,7 @@ export class User extends BaseEntity { @Field(_type => Date, { nullable: true }) @Column({ nullable: true }) - emailConfirmedAt: Date; + emailConfirmedAt: Date | null; @Field(_type => Int, { nullable: true }) async donationsCount() { diff --git a/src/resolvers/userResolver.ts b/src/resolvers/userResolver.ts index 393f9c28b..a6150ab55 100644 --- a/src/resolvers/userResolver.ts +++ b/src/resolvers/userResolver.ts @@ -180,6 +180,14 @@ export class UserResolver { if (!validateEmail(email)) { throw new Error(i18n.__(translationErrorMessagesKeys.INVALID_EMAIL)); } + if (dbUser.email !== email) { + dbUser.emailConfirmed = false; + dbUser.emailConfirmationSent = false; + dbUser.emailConfirmationToken = null; + dbUser.emailConfirmationTokenExpiredAt = null; + dbUser.emailConfirmationSentAt = null; + dbUser.emailConfirmedAt = null; + } dbUser.email = email; } if (url !== undefined) {