feat: email verification (#9081)

* Verify - inital email commit

* Add token type - api redirect - migration

* Redirect and valid api callback route

* Update email design

* Change signup URL to redirect to verify-email

* Add feature flag - add a11y text to email - add top banner

* Shell shouldnt redirect to onboarding if the user needs to verify account

* Move flag check to server

* Cleanup

* Rate limit

* Fix redirects

* Remove api signup mess

* Double negation for forced bool

* Fix props

* Update packages/emails/templates/account-verify-email.ts

* Enable migration by default

* Fix typos

* Fix google verify issue

* Update packages/features/auth/lib/verifyEmail.ts

Co-authored-by: Hariom Balhara <[email protected]>

* NITS: @harioms addressed

* Remove schema changes

* Fix NITs+ improvments

* Update apps/web/pages/api/auth/verify-email.ts

Co-authored-by: Omar López <[email protected]>

* Update packages/features/ee/common/components/LicenseRequired.tsx

Co-authored-by: Omar López <[email protected]>

* Update apps/web/pages/api/auth/verify-email.ts

Co-authored-by: Omar López <[email protected]>

* Always preloads feature flags

* Update verifyEmail.ts

* Update schema.prisma

* Type fix

---------

Co-authored-by: Hariom Balhara <[email protected]>
Co-authored-by: Omar López <[email protected]>
This commit is contained in:
authored and GitHub committed 2023-06-07 07:27:48 +00:00
1 parent 057cf273dd
commit 9e70a985e4
23 files changed
+493 -21

No files matched your search

+11 -2
View File
@@ -18,6 +18,7 @@ import { useFlagMap } from "@calcom/features/flags/context/provider";
import { KBarContent, KBarRoot, KBarTrigger } from "@calcom/features/kbar/Kbar";
import TimezoneChangeDialog from "@calcom/features/settings/TimezoneChangeDialog";
import AdminPasswordBanner from "@calcom/features/users/components/AdminPasswordBanner";
import VerifyEmailBanner from "@calcom/features/users/components/VerifyEmailBanner";
import classNames from "@calcom/lib/classNames";
import { APP_NAME, DESKTOP_APP_LINK, JOIN_SLACK, ROADMAP, WEBAPP_URL } from "@calcom/lib/constants";
import getBrandColours from "@calcom/lib/getBrandColours";
@@ -26,6 +27,7 @@ import { useLocale } from "@calcom/lib/hooks/useLocale";
import { isKeyInObject } from "@calcom/lib/isKeyInObject";
import { trpc } from "@calcom/trpc/react";
import useAvatarQuery from "@calcom/trpc/react/hooks/useAvatarQuery";
import useEmailVerifyCheck from "@calcom/trpc/react/hooks/useEmailVerifyCheck";
import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery";
import type { SVGComponent } from "@calcom/types/SVGComponent";
import {
@@ -123,17 +125,23 @@ function useRedirectToOnboardingIfNeeded() {
const router = useRouter();
const query = useMeQuery();
const user = query.data;
const flags = useFlagMap();
const { data: email } = useEmailVerifyCheck();
const needsEmailVerification = !email?.isVerified && flags["email-verification"];
const isRedirectingToOnboarding = user && shouldShowOnboarding(user);
useEffect(() => {
if (isRedirectingToOnboarding) {
if (isRedirectingToOnboarding && !needsEmailVerification) {
router.replace({
pathname: "/getting-started",
});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isRedirectingToOnboarding]);
}, [isRedirectingToOnboarding, needsEmailVerification]);
return {
isRedirectingToOnboarding,
};
@@ -182,6 +190,7 @@ const Layout = (props: LayoutProps) => {
<TeamsUpgradeBanner />
<ImpersonatingBanner />
<AdminPasswordBanner />
<VerifyEmailBanner />
</div>
<div className="flex flex-1" data-testid="dashboard-shell">
{props.SidebarContainer || <SideBarContainer bannersHeight={bannersHeight} />}