From 427f3a8bd7f21f14aef32af2f7ccf1f4b2731c29 Mon Sep 17 00:00:00 2001 From: Hailey Date: Tue, 12 Nov 2024 11:18:53 -0800 Subject: Add email verification prompts throughout the app (#6174) --- src/lib/hooks/useEmail.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/lib/hooks/useEmail.ts (limited to 'src/lib/hooks/useEmail.ts') diff --git a/src/lib/hooks/useEmail.ts b/src/lib/hooks/useEmail.ts new file mode 100644 index 000000000..6e52846d1 --- /dev/null +++ b/src/lib/hooks/useEmail.ts @@ -0,0 +1,19 @@ +import {useServiceConfigQuery} from '#/state/queries/email-verification-required' +import {useSession} from '#/state/session' +import {BSKY_SERVICE} from '../constants' +import {getHostnameFromUrl} from '../strings/url-helpers' + +export function useEmail() { + const {currentAccount} = useSession() + + const {data: serviceConfig} = useServiceConfigQuery() + + const isSelfHost = + serviceConfig?.checkEmailConfirmed && + currentAccount && + getHostnameFromUrl(currentAccount.service) !== + getHostnameFromUrl(BSKY_SERVICE) + const needsEmailVerification = !isSelfHost && !currentAccount?.emailConfirmed + + return {needsEmailVerification} +} -- cgit 1.4.1 From c0fb5245f1201ac424f6fb2f789510f94fa6d2fc Mon Sep 17 00:00:00 2001 From: Hailey Date: Fri, 15 Nov 2024 17:32:28 -0800 Subject: Tweak email verification dialog (#6397) --- src/components/dialogs/VerifyEmailDialog.tsx | 67 +++++++++++++++++++--------- src/lib/hooks/useEmail.ts | 16 ++++++- 2 files changed, 59 insertions(+), 24 deletions(-) (limited to 'src/lib/hooks/useEmail.ts') diff --git a/src/components/dialogs/VerifyEmailDialog.tsx b/src/components/dialogs/VerifyEmailDialog.tsx index d4412b6f8..ced9171ce 100644 --- a/src/components/dialogs/VerifyEmailDialog.tsx +++ b/src/components/dialogs/VerifyEmailDialog.tsx @@ -146,18 +146,17 @@ export function Inner({ ) : null} - - {currentStep === 'StepOne' ? ( - <> - {!reasonText ? ( - <> - - You'll receive an email at{' '} - - {currentAccount?.email} - {' '} - to verify it's you. - {' '} + {currentStep === 'StepOne' ? ( + + {reasonText ? ( + + {reasonText} + + Don't have access to{' '} + + {currentAccount?.email} + + ?{' '} - Need to change it? + Change your email address - - ) : ( - reasonText - )} - - ) : ( - uiStrings[currentStep].message - )} - + . + + + ) : ( + + + You'll receive an email at{' '} + + {currentAccount?.email} + {' '} + to verify it's you. + {' '} + { + e.preventDefault() + control.close(() => { + openModal({name: 'change-email'}) + }) + return false + }}> + Need to change it? + + + )} + + ) : ( + + {uiStrings[currentStep].message} + + )} {currentStep === 'StepTwo' ? ( diff --git a/src/lib/hooks/useEmail.ts b/src/lib/hooks/useEmail.ts index 6e52846d1..ab87f057e 100644 --- a/src/lib/hooks/useEmail.ts +++ b/src/lib/hooks/useEmail.ts @@ -1,4 +1,5 @@ import {useServiceConfigQuery} from '#/state/queries/email-verification-required' +import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' import {BSKY_SERVICE} from '../constants' import {getHostnameFromUrl} from '../strings/url-helpers' @@ -7,13 +8,24 @@ export function useEmail() { const {currentAccount} = useSession() const {data: serviceConfig} = useServiceConfigQuery() + const {data: profile} = useProfileQuery({did: currentAccount?.did}) + + const checkEmailConfirmed = !!serviceConfig?.checkEmailConfirmed + + const isNewEnough = + !!profile?.createdAt && + Date.parse(profile.createdAt) >= Date.parse('2024-11-16T02:00:00.000Z') const isSelfHost = - serviceConfig?.checkEmailConfirmed && currentAccount && getHostnameFromUrl(currentAccount.service) !== getHostnameFromUrl(BSKY_SERVICE) - const needsEmailVerification = !isSelfHost && !currentAccount?.emailConfirmed + + const needsEmailVerification = + !isSelfHost && + checkEmailConfirmed && + !!currentAccount?.emailConfirmed && + isNewEnough return {needsEmailVerification} } -- cgit 1.4.1 From 9bbea3f33a9a17285d8ec58003b598a911c192a1 Mon Sep 17 00:00:00 2001 From: Hailey Date: Sat, 16 Nov 2024 13:34:30 -0800 Subject: Email verification tweaks (date) (#6416) --- src/lib/hooks/useEmail.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/lib/hooks/useEmail.ts') diff --git a/src/lib/hooks/useEmail.ts b/src/lib/hooks/useEmail.ts index ab87f057e..a8f4c6ad2 100644 --- a/src/lib/hooks/useEmail.ts +++ b/src/lib/hooks/useEmail.ts @@ -12,9 +12,10 @@ export function useEmail() { const checkEmailConfirmed = !!serviceConfig?.checkEmailConfirmed + // Date set for 11 AM PST on the 18th of November const isNewEnough = !!profile?.createdAt && - Date.parse(profile.createdAt) >= Date.parse('2024-11-16T02:00:00.000Z') + Date.parse(profile.createdAt) >= Date.parse('2024-11-18T19:00:00.000Z') const isSelfHost = currentAccount && @@ -24,7 +25,7 @@ export function useEmail() { const needsEmailVerification = !isSelfHost && checkEmailConfirmed && - !!currentAccount?.emailConfirmed && + !currentAccount?.emailConfirmed && isNewEnough return {needsEmailVerification} -- cgit 1.4.1