@@ -19,6 +19,7 @@ import { routes } from "./routes";
1919import { useUser } from "./firebase/hooks" ;
2020import { auth } from "./firebase/firebase" ;
2121import { multiFactor , sendEmailVerification , signOut } from "firebase/auth" ;
22+ import { MultiFactorAuthAssertionScreen , useUI } from "@firebase-ui/react" ;
2223
2324function App ( ) {
2425 const user = useUser ( ) ;
@@ -31,6 +32,13 @@ function App() {
3132}
3233
3334function UnauthenticatedApp ( ) {
35+ const ui = useUI ( ) ;
36+
37+ // This can trigger if the user is not on a screen already, and gets an MFA challenge - e.g. on One-Tap sign in.
38+ if ( ui . multiFactorResolver ) {
39+ return < MultiFactorAuthAssertionScreen /> ;
40+ }
41+
3442 return (
3543 < div className = "max-w-sm mx-auto pt-36 space-y-6 pb-36" >
3644 < div className = "text-center space-y-4" >
@@ -40,7 +48,7 @@ function UnauthenticatedApp() {
4048 Welcome to Firebase UI, choose an example screen below to get started!
4149 </ p >
4250 </ div >
43- < div className = "border border-neutral-800 rounded divide-y divide-neutral-800 overflow-hidden" >
51+ < div className = "border border-neutral-200 dark:border-neutral- 800 rounded divide-y divide-neutral-200 dark: divide-neutral-800 overflow-hidden" >
4452 { routes . map ( ( route ) => (
4553 < Link
4654 key = { route . path }
@@ -51,7 +59,7 @@ function UnauthenticatedApp() {
5159 < h2 className = "font-medium text-sm" > { route . name } </ h2 >
5260 < p className = "text-xs text-gray-400 dark:text-gray-300" > { route . description } </ p >
5361 </ div >
54- < div >
62+ < div className = "text-neutral-600 dark:text-neutral-400" >
5563 < span className = "text-xl" > →</ span >
5664 </ div >
5765 </ Link >
@@ -68,27 +76,32 @@ function AuthenticatedApp() {
6876
6977 return (
7078 < div className = "max-w-sm mx-auto pt-36 space-y-6 pb-36" >
71- < div className = "border border-neutral-800 rounded p-4 space-y-4" >
79+ < div className = "border border-neutral-200 dark:border-neutral- 800 rounded-md p-4 space-y-4" >
7280 < h1 className = "text-md font-medium" > Welcome, { user . displayName || user . email || user . phoneNumber } </ h1 >
73- { user . emailVerified ? (
74- < div className = "text-green-500" > Email verified</ div >
75- ) : (
76- < button
77- className = "bg-red-500 text-white px-3 py-1.5 rounded text-sm"
78- onClick = { async ( ) => {
79- try {
80- await sendEmailVerification ( user ) ;
81- alert ( "Email verification sent, please check your email" ) ;
82- } catch ( error ) {
83- console . error ( error ) ;
84- alert ( "Error sending email verification, check console" ) ;
85- }
86- } }
87- >
88- Verify Email →
89- </ button >
90- ) }
91- < hr className = "opacity-20" />
81+ { user . email ? (
82+ < >
83+ { user . emailVerified ? (
84+ < div className = "text-green-500" > Email verified</ div >
85+ ) : (
86+ < button
87+ className = "bg-red-500 text-white px-3 py-1.5 rounded text-sm"
88+ onClick = { async ( ) => {
89+ try {
90+ await sendEmailVerification ( user ) ;
91+ alert ( "Email verification sent, please check your email" ) ;
92+ } catch ( error ) {
93+ console . error ( error ) ;
94+ alert ( "Error sending email verification, check console" ) ;
95+ }
96+ } }
97+ >
98+ Verify Email →
99+ </ button >
100+ ) }
101+ </ >
102+ ) : null }
103+
104+ < hr className = "opacity-30" />
92105 < h2 className = "text-sm font-medium" > Multi-factor Authentication</ h2 >
93106 { mfa . enrolledFactors . map ( ( factor ) => {
94107 return (
@@ -105,7 +118,7 @@ function AuthenticatedApp() {
105118 >
106119 Add MFA Factor →
107120 </ button >
108- < hr className = "opacity-20 " />
121+ < hr className = "opacity-30 " />
109122 < button
110123 className = "bg-blue-500 text-white px-3 py-1.5 rounded text-sm"
111124 onClick = { async ( ) => await signOut ( auth ) }
0 commit comments