fix: issues with verified emails in workflow#15965
Conversation
| const { user } = ctx; | ||
| const { teamId } = input; | ||
| let verifiedEmails: VerifiedEmail[] = []; | ||
| let verifiedEmails: string[] = [user.email]; |
There was a problem hiding this comment.
user email should show as automatically verified
we only need the emails, so no need to return the whole VerifiedEmail object
There was a problem hiding this comment.
Could it be that the logged in user hasn't verified his email and setting up the workflow?
Would it be okay to consider the email as verified in that case?
| return; | ||
| } | ||
|
|
||
| const userEmail = await prisma.user.findFirst({ |
There was a problem hiding this comment.
if we didn't find verifiedEmail in the db, check if it's the user's email and later if it's one of the team members email
| } | ||
| } | ||
|
|
||
| throw new TRPCError({ code: "NOT_FOUND", message: "Email not verified" }); |
There was a problem hiding this comment.
No entry for verifiedEmail found and it's also not the user's email or any of the team members email
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 3 Skipped Deployments
|
| members: { | ||
| include: { | ||
| user: { | ||
| select: { | ||
| id: true, | ||
| email: true, |
There was a problem hiding this comment.
Should we filter out pending members?
| await prisma.verifiedEmail.create({ | ||
| data: { | ||
| email, | ||
| userId, | ||
| teamId, | ||
| }, | ||
| }); |
There was a problem hiding this comment.
Let's create a repository for VerifiedEmail in a followup.
hariombalhara
left a comment
There was a problem hiding this comment.
Verified that update was failing earlier and is fixed in this branch.
LGTM !! I think we can follow up with some unit tests for verifyEmail
What does this PR do?
getVerifiedEmailsreturned all team members emails as verified, butverifyEmailSenderdidn't which caused issues.Now both look for: the user's email, team members emails, verified emails
How should this be tested?