Skip to content

feat: email verification#9081

Merged
zomars merged 38 commits intomainfrom
feat/email-verify
Jun 7, 2023
Merged

feat: email verification#9081
zomars merged 38 commits intomainfrom
feat/email-verify

Conversation

@sean-brydon
Copy link
Copy Markdown
Member

@sean-brydon sean-brydon commented May 24, 2023

What does this PR do?

Implements email verification controlled by a feature flag

Loom: https://www.loom.com/share/0b0b9302a0e8499fad1d6444b013337c

Environment: Staging(main branch) / Production

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Login as ADMIN
  • Enable Feature flag
  • Verify your account
  • create a new account
  • verify flow works as expected

@vercel
Copy link
Copy Markdown

vercel bot commented May 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2023 2:24am
web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 7, 2023 2:24am
website ❌ Failed (Inspect) Jun 7, 2023 2:24am
2 Ignored Deployments
Name Status Preview Comments Updated (UTC)
api ⬜️ Ignored (Inspect) Visit Preview Jun 7, 2023 2:24am
ui ⬜️ Ignored (Inspect) Visit Preview Jun 7, 2023 2:24am

@github-actions github-actions bot added the ❗️ migrations contains migration files label May 24, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented May 24, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

New Page Added

The following page was added to the bundle from the code in this PR:

Page Size (compressed) First Load % of Budget (350 KB)
/auth/verify-email 89.06 KB 239.85 KB 68.53%

Nine Pages Changed Size

The following pages changed size from the code in this PR compared to its base branch:

Page Size (compressed) First Load % of Budget (350 KB)
/[user]/book 252.42 KB 403.21 KB 115.20% (🟢 -0.27%)
/apps/installed/[category] 276.49 KB 427.28 KB 122.08% (🟢 -0.14%)
/d/[link]/book 252.07 KB 402.86 KB 115.10% (🟢 -0.27%)
/getting-started/[[...step]] 424.71 KB 575.5 KB 164.43% (🟢 -0.22%)
/new-booker/[user]/[type] 288.12 KB 438.91 KB 125.40% (🟢 -0.27%)
/new-booker/d/[link]/[slug] 288.12 KB 438.91 KB 125.40% (🟢 -0.27%)
/new-booker/team/[slug]/[type] 288.12 KB 438.91 KB 125.40% (🟢 -0.27%)
/settings/my-account/calendars 251.06 KB 401.85 KB 114.81% (🟢 -0.17%)
/team/[slug]/book 252.07 KB 402.86 KB 115.10% (🟢 -0.27%)
Details

Only the gzipped size is provided here based on an expert tip.

First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If next/link is used, subsequent page loads would only need to download that page's bundle (the number in the "Size" column), since the global bundle has already been downloaded.

Any third party scripts you have added directly to your app using the <script> tag are not accounted for in this analysis

The "Budget %" column shows what percentage of your performance budget the First Load total takes up. For example, if your budget was 100kb, and a given page's first load size was 10kb, it would be 10% of your budget. You can also see how much this has increased or decreased compared to the base branch of your PR. If this percentage has increased by 20% or more, there will be a red status indicator applied, indicating that special attention should be given to this. If you see "+/- <0.01%" it means that there was a change in bundle size, but it is a trivial enough amount that it can be ignored.

@deploysentinel
Copy link
Copy Markdown

deploysentinel bot commented May 24, 2023

Current Playwright Test Results Summary

✅ 24 Passing - ⚠️ 1 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 06/07/2023 07:27:01am UTC)

Run Details

Running Workflow PR Update on Github Actions

Commit: 1bea5be

Started: 06/07/2023 07:24:58am UTC

⚠️ Flakes

📄   apps/web/playwright/reschedule.e2e.ts • 1 Flake

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Reschedule Tests -- new-booker Should display request reschedule send on bookings/cancelled
Retry 1Initial Attempt
0% (0) 0 / 336 runs
failed over last 7 days
0.30% (1) 1 / 336 run
flaked over last 7 days

View Detailed Build Results


Comment on lines +14 to +19
const foundToken = await prisma.verificationToken.findFirst({
where: {
token,
type: "VERIFY_ACCOUNT",
},
});
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Find the token that is of type verify account

Comment on lines +34 to +36
const hasCompletedOnboarding = user.completedOnboarding;

res.redirect(`${WEBAPP_URL}/${hasCompletedOnboarding ? "/event-types" : "/getting-started"}`);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you have already completed onboarding we redirect to event types

Makes the flow much nicer as you dont get a flash of wrong content

Comment on lines +21 to +26
useEffect(() => {
if (data?.isVerified) {
router.replace("/getting-started");
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data?.isVerified]);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you navigate back to this tab after verifying your account we redirect to straight to getting started

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we just return a new view that says. "Email is already verified"? Maybe add an CTA that takes you back to the dashboard.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think it was clear what i meant by this.

if you switch back to this tab after you have verified your email. It navigates you to getting-started. Meaning you dont have to log in or hard refresh

.then(handleErrors)
.then(async () => {
telemetry.event(telemetryEventTypes.signup, collectPageParameters());
const verifyOrGettingStarted = isEmailVerifyEnabled ? "auth/verify-email" : "getting-started";
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Control where the signup redirect takes you - takes into account the featureflag enabled

@sean-brydon sean-brydon marked this pull request as ready for review May 24, 2023 09:19
@sean-brydon sean-brydon requested a review from zomars as a code owner May 24, 2023 09:19
Comment on lines +27 to +32
const flags = await getFeatureFlagMap(prisma);

if (!flags["email-verification"]) {
log.warn("Email verification is disabled - Skipping");
return { ok: true, skipped: true };
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather use the getFeatureFlagMap on server-side instead of calling individual features.

Copy link
Copy Markdown
Contributor

@zomars zomars left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zomars zomars enabled auto-merge June 7, 2023 02:17
@zomars zomars added this pull request to the merge queue Jun 7, 2023
Merged via the queue into main with commit 9e70a98 Jun 7, 2023
@zomars zomars deleted the feat/email-verify branch June 7, 2023 07:39
@shivamklr shivamklr mentioned this pull request Jun 11, 2023
3 tasks
@shivamklr
Copy link
Copy Markdown
Contributor

@sean-brydon If it is the wrong token, should we not show a proper page? Right now, it only shows the json body. Let me know your thoughts.

@sean-brydon
Copy link
Copy Markdown
Member Author

@sean-brydon If it is the wrong token, should we not show a proper page? Right now, it only shows the json body. Let me know your thoughts.

You're absolutely right - this is something i missed. Would you mind creating an issue on the back of what you have found while writing the test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

✨ feature New feature or request High priority Created by Linear-GitHub Sync ❗️ migrations contains migration files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants