Skip to content

Commit ebf00ed

Browse files
authored
Merge branch 'master' into mc/count
2 parents 7e4874c + 467eaa1 commit ebf00ed

File tree

61 files changed

+394
-73
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+394
-73
lines changed

analytics-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^9.12.1"
9+
"firebase": "^10.0.0"
1010
}
1111
}

appcheck-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^9.12.1"
9+
"firebase": "^10.0.0"
1010
}
1111
}

auth-next/custom-email-handler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ function handleUserManagementQueryParams() {
2828
// Configure the Firebase SDK.
2929
// This is the minimum configuration required for the API to be used.
3030
const config = {
31-
'apiKey': "YOU_API_KEY" // Copy this key from the web initialization
32-
// snippet found in the Firebase console.
31+
'apiKey': "YOUR_API_KEY" // Copy this key from the web initialization
32+
// snippet found in the Firebase console.
3333
};
3434
const app = initializeApp(config);
3535
const auth = getAuth(app);

auth-next/email-link-auth.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ function emailLinkActionCodeSettings() {
1919
installApp: true,
2020
minimumVersion: '12'
2121
},
22-
dynamicLinkDomain: 'example.page.link'
22+
// The domain must be configured in Firebase Hosting and owned by the project.
23+
linkDomain: 'custom-domain.com'
2324
};
2425
// [END auth_email_link_actioncode_settings]
2526
}
@@ -68,11 +69,13 @@ function emailLinkComplete() {
6869
.then((result) => {
6970
// Clear email from storage.
7071
window.localStorage.removeItem('emailForSignIn');
71-
// You can access the new user via result.user
72-
// Additional user info profile not available via:
73-
// result.additionalUserInfo.profile == null
72+
// You can access the new user by importing getAdditionalUserInfo
73+
// and calling it with result:
74+
// getAdditionalUserInfo(result)
75+
// You can access the user's profile via:
76+
// getAdditionalUserInfo(result)?.profile
7477
// You can check if the user is new or existing:
75-
// result.additionalUserInfo.isNewUser
78+
// getAdditionalUserInfo(result)?.isNewUser
7679
})
7780
.catch((error) => {
7881
// Some error occurred, you can inspect the code: error.code

auth-next/email.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ function signUpWithEmailPassword() {
3232
const auth = getAuth();
3333
createUserWithEmailAndPassword(auth, email, password)
3434
.then((userCredential) => {
35-
// Signed in
35+
// Signed up
3636
const user = userCredential.user;
3737
// ...
3838
})

auth-next/emulator-suite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ function emulatorConnect() {
66
const { getAuth, connectAuthEmulator } = require("firebase/auth");
77

88
const auth = getAuth();
9-
connectAuthEmulator(auth, "http://localhost:9099");
9+
connectAuthEmulator(auth, "http://127.0.0.1:9099");
1010
// [END auth_emulator_connect]
1111
}
1212

auth-next/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function authStateListener() {
5252
onAuthStateChanged(auth, (user) => {
5353
if (user) {
5454
// User is signed in, see docs for a list of available properties
55-
// https://firebase.google.com/docs/reference/js/firebase.User
55+
// https://firebase.google.com/docs/reference/js/v8/firebase.User
5656
const uid = user.uid;
5757
// ...
5858
} else {
@@ -72,7 +72,7 @@ function currentUser() {
7272

7373
if (user) {
7474
// User is signed in, see docs for a list of available properties
75-
// https://firebase.google.com/docs/reference/js/firebase.User
75+
// https://firebase.google.com/docs/reference/js/v8/firebase.User
7676
// ...
7777
} else {
7878
// No user is signed in.
@@ -87,7 +87,7 @@ function setLanguageCode() {
8787
const auth = getAuth();
8888
auth.languageCode = 'it';
8989
// To apply the default browser preference instead of explicitly setting it.
90-
// firebase.auth().useDeviceLanguage();
90+
// auth.useDeviceLanguage();
9191
// [END auth_set_language_code]
9292
}
9393

auth-next/link-multiple-accounts.js

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,61 @@ function unlink(providerId) {
182182
});
183183
// [END auth_unlink_provider]
184184
}
185+
186+
function accountExistsPopup(auth, facebookProvider, goToApp, promptUserForPassword, promptUserForSignInMethod, getProviderForProviderId) {
187+
// [START account_exists_popup]
188+
const { signInWithPopup, signInWithEmailAndPassword, linkWithCredential } = require("firebase/auth");
189+
190+
// User tries to sign in with Facebook.
191+
signInWithPopup(auth, facebookProvider).catch((error) => {
192+
// User's email already exists.
193+
if (error.code === 'auth/account-exists-with-different-credential') {
194+
// The pending Facebook credential.
195+
const pendingCred = error.credential;
196+
// The provider account's email address.
197+
const email = error.customData.email;
198+
199+
// Present the user with a list of providers they might have
200+
// used to create the original account.
201+
// Then, ask the user to sign in with the existing provider.
202+
const method = promptUserForSignInMethod();
203+
204+
if (method === 'password') {
205+
// TODO: Ask the user for their password.
206+
// In real scenario, you should handle this asynchronously.
207+
const password = promptUserForPassword();
208+
signInWithEmailAndPassword(auth, email, password).then((result) => {
209+
return linkWithCredential(result.user, pendingCred);
210+
}).then(() => {
211+
// Facebook account successfully linked to the existing user.
212+
goToApp();
213+
});
214+
return;
215+
}
216+
217+
// All other cases are external providers.
218+
// Construct provider object for that provider.
219+
// TODO: Implement getProviderForProviderId.
220+
const provider = getProviderForProviderId(method);
221+
// At this point, you should let the user know that they already have an
222+
// account with a different provider, and validate they want to sign in
223+
// with the new provider.
224+
// Note: Browsers usually block popups triggered asynchronously, so in
225+
// real app, you should ask the user to click on a "Continue" button
226+
// that will trigger signInWithPopup().
227+
signInWithPopup(auth, provider).then((result) => {
228+
// Note: Identity Platform doesn't control the provider's sign-in
229+
// flow, so it's possible for the user to sign in with an account
230+
// with a different email from the first one.
231+
232+
// Link the Facebook credential. We have access to the pending
233+
// credential, so we can directly call the link method.
234+
linkWithCredential(result.user, pendingCred).then((userCred) => {
235+
// Success.
236+
goToApp();
237+
});
238+
});
239+
}
240+
});
241+
// [END account_exists_popup]
242+
}

auth-next/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"license": "Apache-2.0",
88
"dependencies": {
9-
"firebase": "^9.12.1"
9+
"firebase": "^10.0.0"
1010
}
1111
}

auth-next/phone-auth.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ function recaptchaVerifierInvisible() {
1515
const { getAuth, RecaptchaVerifier } = require("firebase/auth");
1616

1717
const auth = getAuth();
18-
window.recaptchaVerifier = new RecaptchaVerifier('sign-in-button', {
18+
window.recaptchaVerifier = new RecaptchaVerifier(auth, 'sign-in-button', {
1919
'size': 'invisible',
2020
'callback': (response) => {
2121
// reCAPTCHA solved, allow signInWithPhoneNumber.
2222
onSignInSubmit();
2323
}
24-
}, auth);
24+
});
2525
// [END auth_phone_recaptcha_verifier_invisible]
2626
}
2727

@@ -30,7 +30,7 @@ function recaptchaVerifierVisible() {
3030
const { getAuth, RecaptchaVerifier } = require("firebase/auth");
3131

3232
const auth = getAuth();
33-
window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {
33+
window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', {
3434
'size': 'normal',
3535
'callback': (response) => {
3636
// reCAPTCHA solved, allow signInWithPhoneNumber.
@@ -40,7 +40,7 @@ function recaptchaVerifierVisible() {
4040
// Response expired. Ask user to solve reCAPTCHA again.
4141
// ...
4242
}
43-
}, auth);
43+
});
4444
// [END auth_phone_recaptcha_verifier_visible]
4545
}
4646

@@ -49,7 +49,7 @@ function recaptchaVerifierSimple() {
4949
const { getAuth, RecaptchaVerifier } = require("firebase/auth");
5050

5151
const auth = getAuth();
52-
window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {}, auth);
52+
window.recaptchaVerifier = new RecaptchaVerifier(auth, 'recaptcha-container', {});
5353
// [END auth_phone_recaptcha_verifier_simple]
5454
}
5555

0 commit comments

Comments
 (0)