From 0cd2206e95816b966b10f60a71ef7895829302c1 Mon Sep 17 00:00:00 2001 From: tolgahan-arikan Date: Tue, 10 Sep 2024 15:23:15 +0300 Subject: [PATCH] Remove deprecated email auth version usage (#47) --- src/Login.tsx | 55 ++++---------- src/components/views/ListAccountsView.tsx | 17 +---- src/utils/useEmailAuth.ts | 91 ++++++++++++++++------ src/utils/useEmailAuthV2.ts | 92 ----------------------- 4 files changed, 85 insertions(+), 170 deletions(-) delete mode 100644 src/utils/useEmailAuthV2.ts diff --git a/src/Login.tsx b/src/Login.tsx index c91142a..821f8ec 100644 --- a/src/Login.tsx +++ b/src/Login.tsx @@ -1,4 +1,4 @@ -import { Box, Text, TextInput, Button, Spinner, Checkbox, Divider, Modal, Switch } from '@0xsequence/design-system' +import { Box, Text, TextInput, Button, Spinner, Divider, Modal, Switch } from '@0xsequence/design-system' import { SetStateAction, useEffect, useRef, useState } from 'react' import { CredentialResponse, GoogleLogin, useGoogleLogin } from '@react-oauth/google' import AppleSignin from 'react-apple-signin-auth' @@ -11,7 +11,6 @@ import { EmailConflictWarning } from './components/views/EmailConflictWarningVie import { randomName } from './utils/indexer' import { useEmailAuth } from './utils/useEmailAuth.ts' -import { useEmailAuthV2 } from './utils/useEmailAuthV2.ts' import { StytchLogin } from './components/StytchLogin.tsx' import { StytchLegacyLogin } from './components/StytchLegacyLogin.tsx' import { EmailConflictInfo } from '@0xsequence/waas' @@ -23,8 +22,6 @@ function Login() { const [showEmailWarning, setEmailWarning] = useState(false) const [code, setCode] = useState([]) - const [isEmailV2Enabled, setIsEmailV2Enabled] = useState(true) - const [emailConflictInfo, setEmailConflictInfo] = useState() const [isEmailConflictModalOpen, setIsEmailConflictModalOpen] = useState(false) const forceCreateFuncRef = useRef<(() => Promise) | null>(null) @@ -68,12 +65,12 @@ function Login() { }) const { - inProgress: emailV2AuthInProgress, - loading: emailV2AuthLoading, - initiateAuth: initiateEmailV2Auth, - sendChallengeAnswer: sendChallengeAnswerV2, - cancel: cancelEmailV2Auth - } = useEmailAuthV2({ + inProgress: emailAuthInProgress, + loading: emailAuthLoading, + initiateAuth: initiateEmailAuth, + sendChallengeAnswer, + cancel: cancelEmailAuth + } = useEmailAuth({ sessionName: randomName(), onSuccess: async ({ wallet }) => { console.log(`Wallet address: ${wallet}`) @@ -81,24 +78,6 @@ function Login() { } }) - const { - inProgress: emailV1AuthInProgress, - loading: emailV1AuthLoading, - initiateAuth: initiateEmailV1Auth, - sendChallengeAnswer: sendChallengeAnswerV1 - } = useEmailAuth({ - onSuccess: async idToken => { - const walletAddress = await sequence.signIn({ idToken }, randomName()) - console.log(`Wallet address: ${walletAddress}`) - router.navigate('/') - } - }) - - const emailAuthInProgress = isEmailV2Enabled ? emailV2AuthInProgress : emailV1AuthInProgress - const emailAuthLoading = isEmailV2Enabled ? emailV2AuthLoading : emailV1AuthLoading - const initiateEmailAuth = isEmailV2Enabled ? initiateEmailV2Auth : initiateEmailV1Auth - const sendChallengeAnswer = isEmailV2Enabled ? sendChallengeAnswerV2 : sendChallengeAnswerV1 - useEffect(() => { ;(async () => { if (await sequence.isSignedIn()) { @@ -168,8 +147,14 @@ function Login() { + + + Guest Login + + + -