Skip to content

Commit

Permalink
Reset email verification in email update
Browse files Browse the repository at this point in the history
  • Loading branch information
ae2079 committed Aug 14, 2024
1 parent 0e33d29 commit 483543d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/entities/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions src/resolvers/userResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 483543d

Please sign in to comment.