Skip to content

Commit

Permalink
chore(core): sync email address to notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
bodymindarts committed Feb 16, 2024
1 parent 0a2f0b8 commit 8df532e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/api/src/app/authentication/email.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { AccountAlreadyHasEmailError } from "@/domain/authentication/errors"
import { AuthWithEmailPasswordlessService } from "@/services/kratos"
import { baseLogger } from "@/services/logger"
import { UsersRepository } from "@/services/mongoose"
import { NotificationsService } from "@/services/notifications"

export const addEmailToIdentity = async ({
email,
Expand All @@ -25,6 +26,8 @@ export const addEmailToIdentity = async ({
const emailRegistrationId = await authServiceEmail.sendEmailWithCode({ email })
if (emailRegistrationId instanceof Error) return emailRegistrationId

await NotificationsService().updateEmailAddress({ userId, email })

const user = await UsersRepository().findById(userId)
if (user instanceof Error) return user

Expand Down Expand Up @@ -74,5 +77,7 @@ export const removeEmail = async ({
})
if (updatedUser instanceof Error) return updatedUser

await NotificationsService().removeEmailAddress({ userId })

return user
}

0 comments on commit 8df532e

Please sign in to comment.