diff --git a/auth-next/index.js b/auth-next/index.js index 73d33219..c4dadfe0 100644 --- a/auth-next/index.js +++ b/auth-next/index.js @@ -26,7 +26,7 @@ function makeFacebookCredential(response) { function makeEmailCredential(email, password) { // [START auth_make_email_credential] const { EmailAuthProvider } = require("firebase/auth"); - + const credential = EmailAuthProvider.credential(email, password); // [END auth_make_email_credential] } @@ -121,3 +121,17 @@ function signInRedirect(provider) { signInWithRedirect(auth, provider); // [END auth_signin_redirect] } + +function initializeWithCustomDomain() { + // [START auth_init_custom_domain] + const { initializeApp } = require("firebase/app"); + + const firebaseConfig = { + apiKey: "...", + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' + }; + const firebaseApp = initializeApp(firebaseConfig); + // [END auth_init_custom_domain] +} diff --git a/auth/index.js b/auth/index.js index 6ea5d587..6567c030 100644 --- a/auth/index.js +++ b/auth/index.js @@ -101,3 +101,14 @@ function signInRedirect(provider) { firebase.auth().signInWithRedirect(provider); // [END auth_signin_redirect] } + +function initializeWithCustomDomain() { + // [START auth_init_custom_domain] + firebase.initializeApp({ + apiKey: '...', + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' + }); + // [END auth_init_custom_domain] +} diff --git a/auth/oidc.js b/auth/oidc.js index 4c056e52..e3a3e01e 100644 --- a/auth/oidc.js +++ b/auth/oidc.js @@ -4,9 +4,6 @@ import firebase from "firebase/app"; import "firebase/auth"; -// [SNIPPET_REGISTRY disabled] -// [SNIPPETS_SEPARATION enabled] - function oidcProvider() { // [START auth_oidc_provider_create] const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); diff --git a/auth/saml.js b/auth/saml.js index a55b691c..e3a99cde 100644 --- a/auth/saml.js +++ b/auth/saml.js @@ -4,9 +4,6 @@ import firebase from "firebase/app"; import "firebase/auth"; -// [SNIPPET_REGISTRY disabled] -// [SNIPPETS_SEPARATION enabled] - function samlProvider() { // [START auth_saml_provider_create] const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); diff --git a/snippets/auth-next/index/auth_init_custom_domain.js b/snippets/auth-next/index/auth_init_custom_domain.js new file mode 100644 index 00000000..971e5c56 --- /dev/null +++ b/snippets/auth-next/index/auth_init_custom_domain.js @@ -0,0 +1,17 @@ +// This snippet file was generated by processing the source file: +// ./auth-next/index.js +// +// To update the snippets in this file, edit the source and then run +// 'npm run snippets'. + +// [START auth_init_custom_domain_modular] +import { initializeApp } from "firebase/app"; + +const firebaseConfig = { + apiKey: "...", + // By default, authDomain is '[YOUR_APP].firebaseapp.com'. + // You may replace it with a custom domain. + authDomain: '[YOUR_CUSTOM_DOMAIN]' +}; +const firebaseApp = initializeApp(firebaseConfig); +// [END auth_init_custom_domain_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_direct_sign_in.js b/snippets/auth/oidc/auth_oidc_direct_sign_in.js deleted file mode 100644 index 5a0c629d..00000000 --- a/snippets/auth/oidc/auth_oidc_direct_sign_in.js +++ /dev/null @@ -1,19 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_direct_sign_in_modular] -const credential = provider.credential(oidcIdToken, null); - -firebase.auth().signInWithCredential(credential) - .then((result) => { - // User is signed in. - // User now has a odic.myProvider UserInfo in providerData. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_oidc_direct_sign_in_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_provider_create.js b/snippets/auth/oidc/auth_oidc_provider_create.js deleted file mode 100644 index 09e08ad8..00000000 --- a/snippets/auth/oidc/auth_oidc_provider_create.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_provider_create_modular] -const provider = new firebase.auth.OAuthProvider('oidc.myProvider'); -// [END auth_oidc_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_popup.js b/snippets/auth/oidc/auth_oidc_signin_popup.js deleted file mode 100644 index c5ff4afa..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_popup.js +++ /dev/null @@ -1,18 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_popup_modular] -firebase.auth().signInWithPopup(provider) - .then((result) => { - // User is signed in. - // result.credential is a firebase.auth().OAuthCredential object. - // result.credential.providerId is equal to 'oidc.myProvider'. - // result.credential.idToken is the OIDC provider's ID token. - }) - .catch((error) => { - // Handle error. - }); -// [END auth_oidc_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect.js b/snippets/auth/oidc/auth_oidc_signin_redirect.js deleted file mode 100644 index 4951c4bf..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_redirect.js +++ /dev/null @@ -1,11 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_redirect_modular] -firebase.auth().signInWithRedirect(provider).catch((error) => { - // Handle error. -}); -// [END auth_oidc_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/oidc/auth_oidc_signin_redirect_result.js b/snippets/auth/oidc/auth_oidc_signin_redirect_result.js deleted file mode 100644 index 2cd0eaa7..00000000 --- a/snippets/auth/oidc/auth_oidc_signin_redirect_result.js +++ /dev/null @@ -1,20 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/oidc.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_oidc_signin_redirect_result_modular] -// On return. -firebase.auth().getRedirectResult() - .then((result) => { - // User is signed in. - // result.credential is a firebase.auth().OAuthCredential object. - // result.credential.providerId is equal to 'oidc.myProvider'. - // result.credential.idToken is the OIDC provider's ID token. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_oidc_signin_redirect_result_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_provider_create.js b/snippets/auth/saml/auth_saml_provider_create.js deleted file mode 100644 index a9765e5e..00000000 --- a/snippets/auth/saml/auth_saml_provider_create.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_provider_create_modular] -const provider = new firebase.auth.SAMLAuthProvider('saml.myProvider'); -// [END auth_saml_provider_create_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_popup.js b/snippets/auth/saml/auth_saml_signin_popup.js deleted file mode 100644 index 1fb3b4f6..00000000 --- a/snippets/auth/saml/auth_saml_signin_popup.js +++ /dev/null @@ -1,21 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_popup_modular] -firebase.auth().signInWithPopup(provider) - .then((result) => { - // User is signed in. - // Identity provider data available in result.additionalUserInfo.profile, - // or from the user's ID token obtained from result.user.getIdToken() - // as an object in the firebase.sign_in_attributes custom claim - // This is also available from result.user.getIdTokenResult() - // idTokenResult.claims.firebase.sign_in_attributes. - }) - .catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_saml_signin_popup_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect.js b/snippets/auth/saml/auth_saml_signin_redirect.js deleted file mode 100644 index bd328a57..00000000 --- a/snippets/auth/saml/auth_saml_signin_redirect.js +++ /dev/null @@ -1,9 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_redirect_modular] -firebase.auth().signInWithRedirect(provider); -// [END auth_saml_signin_redirect_modular] \ No newline at end of file diff --git a/snippets/auth/saml/auth_saml_signin_redirect_result.js b/snippets/auth/saml/auth_saml_signin_redirect_result.js deleted file mode 100644 index 65a9f38b..00000000 --- a/snippets/auth/saml/auth_saml_signin_redirect_result.js +++ /dev/null @@ -1,20 +0,0 @@ -// This snippet file was generated by processing the source file: -// ./auth/saml.js -// -// To update the snippets in this file, edit the source and then run -// 'npm run snippets'. - -// [START auth_saml_signin_redirect_result_modular] -firebase.auth().getRedirectResult() - .then((result) => { - // User is signed in. - // Provider data available in result.additionalUserInfo.profile, - // or from the user's ID token obtained from result.user.getIdToken() - // as an object in the firebase.sign_in_attributes custom claim - // This is also available from result.user.getIdTokenResult() - // idTokenResult.claims.firebase.sign_in_attributes. - }).catch((error) => { - // Handle / display error. - // ... - }); -// [END auth_saml_signin_redirect_result_modular] \ No newline at end of file