11/* eslint-disable no-console */
22import "./App.css" ;
3- import { useWeb3AuthConnect , useWeb3AuthDisconnect , useWeb3AuthUser } from "@web3auth/modal/react" ;
3+ import { useWeb3AuthConnect , useWeb3AuthDisconnect , useWeb3AuthUser , useManageMFA , useEnableMFA } from "@web3auth/modal/react" ;
44import { WALLET_CONNECTORS , AUTH_CONNECTION } from "@web3auth/modal" ;
55import { useAccount } from "wagmi" ;
66import { SendTransaction } from "./components/sendTransaction" ;
77import { Balance } from "./components/getBalance" ;
88import { SwitchChain } from "./components/switchNetwork" ;
99import { initializeApp } from "firebase/app" ;
10- import { getAuth , GithubAuthProvider , signInWithPopup } from "firebase/auth" ;
10+ import { getAuth , GoogleAuthProvider , signInWithPopup } from "firebase/auth" ;
1111
1212// Firebase configuration
1313const firebaseConfig = {
@@ -24,19 +24,21 @@ function App() {
2424 const { disconnect, loading : disconnectLoading , error : disconnectError } = useWeb3AuthDisconnect ( ) ;
2525 const { userInfo } = useWeb3AuthUser ( ) ;
2626 const { address } = useAccount ( ) ;
27+ const { manageMFA, loading : manageMFALoading , error : manageMFAError } = useManageMFA ( ) ;
28+ const { enableMFA, loading : enableMFALoading , error : enableMFAError } = useEnableMFA ( ) ;
2729
28- const loginWithFirebaseGithub = async ( ) => {
30+ const loginWithFirebaseGoogle = async ( ) => {
2931 try {
3032 const app = initializeApp ( firebaseConfig ) ;
3133 const auth = getAuth ( app ) ;
32- const githubProvider = new GithubAuthProvider ( ) ;
34+ const googleProvider = new GoogleAuthProvider ( ) ;
3335
34- const result = await signInWithPopup ( auth , githubProvider ) ;
36+ const result = await signInWithPopup ( auth , googleProvider ) ;
3537
3638 const idToken = await result . user . getIdToken ( true ) ;
3739
3840 connectTo ( WALLET_CONNECTORS . AUTH , {
39- authConnectionId : "w3a-firebase-demo" ,
41+ authConnectionId : "w3a-firebase-demo-new " ,
4042 authConnection : AUTH_CONNECTION . CUSTOM ,
4143 idToken,
4244 extraLoginOptions : {
@@ -73,6 +75,20 @@ function App() {
7375 { disconnectLoading && < div className = "loading" > Disconnecting...</ div > }
7476 { disconnectError && < div className = "error" > { disconnectError . message } </ div > }
7577 </ div >
78+ < div >
79+ < button onClick = { ( ) => enableMFA ( ) } className = "card" >
80+ Enable MFA
81+ </ button >
82+ { enableMFALoading && < div className = "loading" > Enabling MFA...</ div > }
83+ { enableMFAError && < div className = "error" > { enableMFAError . message } </ div > }
84+ </ div >
85+ < div >
86+ < button onClick = { ( ) => manageMFA ( ) } className = "card" >
87+ Manage MFA
88+ </ button >
89+ { manageMFALoading && < div className = "loading" > Managing MFA...</ div > }
90+ { manageMFAError && < div className = "error" > { manageMFAError . message } </ div > }
91+ </ div >
7692 </ div >
7793 < SendTransaction />
7894 < Balance />
@@ -83,8 +99,8 @@ function App() {
8399 const unloggedInView = (
84100 < div className = "grid" >
85101 < div className = "flex-container" >
86- < button onClick = { loginWithFirebaseGithub } className = "card" >
87- Login with Firebase GitHub
102+ < button onClick = { loginWithFirebaseGoogle } className = "card" >
103+ Login with Firebase Google
88104 </ button >
89105 </ div >
90106 { connectLoading && < div className = "loading" > Connecting...</ div > }
0 commit comments