Skip to content

Commit 469cf12

Browse files
committed
fix: Update UI state + example app
1 parent 2ba8442 commit 469cf12

File tree

8 files changed

+41
-20
lines changed

8 files changed

+41
-20
lines changed

examples/nextjs/lib/firebase/clientApp.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ export const auth = getAuth(firebaseApp);
1313

1414
export const ui = initializeUI({
1515
app: firebaseApp,
16-
tosUrl: "https://www.google.com",
17-
privacyPolicyUrl: "https://www.google.com",
1816
behaviors: [autoAnonymousLogin()],
1917
translations: [
2018
customLanguage(english.locale, {

examples/nextjs/lib/firebase/ui.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,15 @@ export function FirebaseUIProvider({
88
}: {
99
children: React.ReactNode;
1010
}) {
11-
return <ConfigProvider ui={ui}>{children}</ConfigProvider>;
11+
return (
12+
<ConfigProvider
13+
ui={ui}
14+
policies={{
15+
termsOfServiceUrl: "https://www.google.com",
16+
privacyPolicyUrl: "https://www.google.com",
17+
}}
18+
>
19+
{children}
20+
</ConfigProvider>
21+
);
1222
}

packages/firebaseui-core/src/auth.ts

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,11 @@ export async function signInWithEmailAndPassword(
5757

5858
ui.setState('signing-in');
5959
const result = await signInWithCredential(auth, credential);
60-
ui.setState('idle');
6160
return handlePendingCredential(ui, result);
6261
} catch (error) {
6362
handleFirebaseError(ui, error);
63+
} finally {
64+
ui.setState('idle');
6465
}
6566
}
6667

@@ -83,10 +84,11 @@ export async function createUserWithEmailAndPassword(
8384

8485
ui.setState('creating-user');
8586
const result = await _createUserWithEmailAndPassword(auth, email, password);
86-
ui.setState('idle');
8787
return handlePendingCredential(ui, result);
8888
} catch (error) {
8989
handleFirebaseError(ui, error);
90+
} finally {
91+
ui.setState('idle');
9092
}
9193
}
9294

@@ -98,11 +100,11 @@ export async function signInWithPhoneNumber(
98100
try {
99101
const auth = getAuth(ui.app);
100102
ui.setState('signing-in');
101-
const result = await _signInWithPhoneNumber(auth, phoneNumber, recaptchaVerifier);
102-
ui.setState('idle');
103-
return result;
103+
return await _signInWithPhoneNumber(auth, phoneNumber, recaptchaVerifier);
104104
} catch (error) {
105105
handleFirebaseError(ui, error);
106+
} finally {
107+
ui.setState('idle');
106108
}
107109
}
108110

@@ -126,10 +128,11 @@ export async function confirmPhoneNumber(
126128

127129
ui.setState('signing-in');
128130
const result = await signInWithCredential(auth, credential);
129-
ui.setState('idle');
130131
return handlePendingCredential(ui, result);
131132
} catch (error) {
132133
handleFirebaseError(ui, error);
134+
} finally {
135+
ui.setState('idle');
133136
}
134137
}
135138

@@ -138,9 +141,10 @@ export async function sendPasswordResetEmail(ui: FirebaseUIConfiguration, email:
138141
const auth = getAuth(ui.app);
139142
ui.setState('sending-password-reset-email');
140143
await _sendPasswordResetEmail(auth, email);
141-
ui.setState('idle');
142144
} catch (error) {
143145
handleFirebaseError(ui, error);
146+
} finally {
147+
ui.setState('idle');
144148
}
145149
}
146150

@@ -156,10 +160,11 @@ export async function sendSignInLinkToEmail(ui: FirebaseUIConfiguration, email:
156160

157161
ui.setState('sending-sign-in-link-to-email');
158162
await _sendSignInLinkToEmail(auth, email, actionCodeSettings);
159-
ui.setState('idle');
160163
window.localStorage.setItem('emailForSignIn', email);
161164
} catch (error) {
162165
handleFirebaseError(ui, error);
166+
} finally {
167+
ui.setState('idle');
163168
}
164169
}
165170

@@ -181,10 +186,11 @@ export async function signInWithEmailLink(
181186

182187
ui.setState('signing-in');
183188
const result = await signInWithCredential(auth, credential);
184-
ui.setState('idle');
185189
return handlePendingCredential(ui, result);
186190
} catch (error) {
187191
handleFirebaseError(ui, error);
192+
} finally {
193+
ui.setState('idle');
188194
}
189195
}
190196

@@ -193,10 +199,11 @@ export async function signInAnonymously(ui: FirebaseUIConfiguration): Promise<Us
193199
const auth = getAuth(ui.app);
194200
ui.setState('signing-in');
195201
const result = await _signInAnonymously(auth);
196-
ui.setState('idle');
197202
return handlePendingCredential(ui, result);
198203
} catch (error) {
199204
handleFirebaseError(ui, error);
205+
} finally {
206+
ui.setState('idle');
200207
}
201208
}
202209

@@ -216,6 +223,8 @@ export async function signInWithOAuth(ui: FirebaseUIConfiguration, provider: Aut
216223
// If we support popups, we'd need to modify state here.
217224
} catch (error) {
218225
handleFirebaseError(ui, error);
226+
} finally {
227+
ui.setState('idle');
219228
}
220229
}
221230

@@ -239,6 +248,7 @@ export async function completeEmailLinkSignIn(
239248
} catch (error) {
240249
handleFirebaseError(ui, error);
241250
} finally {
251+
ui.setState('idle');
242252
window.localStorage.removeItem('emailForSignIn');
243253
}
244254
}

packages/firebaseui-react/src/auth/forms/email-link-form.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ export function EmailLinkForm(_: EmailLinkFormProps) {
7070
}, [auth, ui.translations]);
7171

7272
if (emailSent) {
73-
// TODO: Improve this UI
74-
return <div>{getTranslation(ui, "messages", "signInLinkSent")}</div>;
73+
return <div className="fui-success">{getTranslation(ui, "messages", "signInLinkSent")}</div>;
7574
}
7675

7776
return (

packages/firebaseui-react/src/auth/forms/forgot-password-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function ForgotPasswordForm({
5858

5959
if (emailSent) {
6060
return (
61-
<div className="fui-form__success">
61+
<div className="fui-success">
6262
{getTranslation(ui, "messages", "checkEmailForReset")}
6363
</div>
6464
);

packages/firebaseui-react/src/components/policies.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function Policies() {
6969
onClick={() => handleUrl(termsOfServiceUrl)}
7070
target="_blank"
7171
rel="noopener noreferrer"
72-
className="text-text-muted hover:underline text-xs"
72+
className="text-text-muted hover:underline font-semibold"
7373
>
7474
{termsText}
7575
</a>
@@ -82,7 +82,7 @@ export function Policies() {
8282
onClick={() => handleUrl(privacyPolicyUrl)}
8383
target="_blank"
8484
rel="noopener noreferrer"
85-
className="text-text-muted hover:underline text-xs"
85+
className="text-text-muted hover:underline font-semibold"
8686
>
8787
{privacyText}
8888
</a>

0 commit comments

Comments
 (0)