Skip to content

Commit b551eeb

Browse files
committed
feat(core,react,styles,translations): Add MFA enrollment screens/forms
1 parent 9e715da commit b551eeb

19 files changed

+1256
-32
lines changed

examples/react/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
"@firebase-ui/styles": "workspace:*",
1919
"@firebase-ui/translations": "workspace:*",
2020
"firebase": "^11.6.0",
21-
"react": "^19.0.0",
22-
"react-dom": "^19.0.0",
21+
"react": "catalog:",
22+
"react-dom": "catalog:",
2323
"react-router": "^7.5.1"
2424
},
2525
"devDependencies": {
2626
"@tailwindcss/vite": "^4.1.4",
2727
"@eslint/js": "^9.22.0",
28-
"@types/react": "^19.0.10",
29-
"@types/react-dom": "^19.0.4",
28+
"@types/react": "catalog:",
29+
"@types/react-dom": "catalog:",
3030
"@vitejs/plugin-react": "^4.3.4",
3131
"eslint": "^9.22.0",
3232
"eslint-plugin-react-hooks": "^5.2.0",

examples/react/src/App.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ function App() {
8282
Password Reset Screen
8383
</NavLink>
8484
</li>
85+
<li>
86+
<NavLink to="/screens/mfa-enrollment-screen" className="text-blue-500 hover:underline">
87+
MFA Enrollment Screen
88+
</NavLink>
89+
</li>
8590
</ul>
8691
</div>
8792
</div>

examples/react/src/firebase/config.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,11 @@
1414
* limitations under the License.
1515
*/
1616

17-
export const firebaseConfig = {};
17+
export const firebaseConfig = {
18+
apiKey: "AIzaSyCvMftIUCD9lUQ3BzIrimfSfBbCUQYZf-I",
19+
authDomain: "fir-ui-rework.firebaseapp.com",
20+
projectId: "fir-ui-rework",
21+
storageBucket: "fir-ui-rework.firebasestorage.app",
22+
messagingSenderId: "200312857118",
23+
appId: "1:200312857118:web:94e3f69b0e0a4a863f040f"
24+
};

examples/react/src/main.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ import OAuthScreenPage from "./screens/oauth-screen";
4747
/** Password Reset */
4848
import ForgotPasswordPage from "./screens/forgot-password-screen";
4949

50+
/** MFA Enrollment */
51+
import MultiFactorAuthEnrollmentScreenPage from "./screens/mfa-enrollment-screen";
52+
5053
const root = document.getElementById("root")!;
5154

5255
ReactDOM.createRoot(root).render(
@@ -72,6 +75,7 @@ ReactDOM.createRoot(root).render(
7275
<Route path="/screens/sign-up-auth-screen-w-oauth" element={<SignUpAuthScreenWithOAuthPage />} />
7376
<Route path="/screens/oauth-screen" element={<OAuthScreenPage />} />
7477
<Route path="/screens/forgot-password-screen" element={<ForgotPasswordPage />} />
78+
<Route path="/screens/mfa-enrollment-screen" element={<MultiFactorAuthEnrollmentScreenPage />} />
7579
</Routes>
7680
</FirebaseUIProvider>
7781
</BrowserRouter>
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/**
2+
* Copyright 2025 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
"use client";
18+
19+
import { MultiFactorAuthEnrollmentScreen } from "@firebase-ui/react";
20+
import { FactorId } from "firebase/auth";
21+
22+
export default function MultiFactorAuthEnrollmentScreenPage() {
23+
return <MultiFactorAuthEnrollmentScreen
24+
hints={[FactorId.TOTP, FactorId.PHONE]}
25+
onEnrollment={() => {
26+
console.log("Enrollment successful");
27+
}}
28+
/>;
29+
}

packages/core/src/schemas.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ export function createPhoneAuthVerifyFormSchema(ui: FirebaseUI) {
7676
export function createMultiFactorPhoneAuthNumberFormSchema(ui: FirebaseUI) {
7777
const base = createPhoneAuthNumberFormSchema(ui);
7878
return base.extend({
79-
// TODO(ehesp): Translation...
80-
displayName: z.string().min(1, "TODO!"),
79+
displayName: z.string().min(1, getTranslation(ui, "errors", "displayNameRequired")),
8180
});
8281
}
8382

0 commit comments

Comments
 (0)