Skip to content

fix error handling on v9 auth snippets #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions auth-next/apple.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function appleSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down Expand Up @@ -85,7 +85,7 @@ function appleSignInRedirectResult() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down Expand Up @@ -123,7 +123,7 @@ function appleReauthenticatePopup() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down
8 changes: 4 additions & 4 deletions auth-next/facebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function facebookSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);

Expand All @@ -66,7 +66,7 @@ function facebookSignInRedirectResult() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down Expand Up @@ -102,7 +102,7 @@ function checkLoginState_wrapper() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down Expand Up @@ -156,7 +156,7 @@ function authWithCredential(credential) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down
4 changes: 2 additions & 2 deletions auth-next/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function githubSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GithubAuthProvider.credentialFromError(error);
// ...
Expand Down Expand Up @@ -75,7 +75,7 @@ function githubSignInRedirectResult() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GithubAuthProvider.credentialFromError(error);
// ...
Expand Down
8 changes: 4 additions & 4 deletions auth-next/google-signin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function googleSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand All @@ -65,7 +65,7 @@ function googleSignInRedirectResult() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand All @@ -87,7 +87,7 @@ function googleBuildAndSignIn(id_token) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down Expand Up @@ -123,7 +123,7 @@ function onSignIn_wrapper() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
2 changes: 1 addition & 1 deletion auth-next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function authWithCredential(credential) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// ...
});
// [END auth_signin_credential]
Expand Down
4 changes: 2 additions & 2 deletions auth-next/multi-tenancy.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function accountExistsPopupTenant(auth, samlProvider, googleProvider, goToApp) {
const pendingCred = error.credential;
// The credential's tenantId if needed: error.tenantId
// The provider account's email address.
const email = error.email;
const email = error.customData.email;
// Get sign-in methods for this email.
fetchSignInMethodsForEmail(email, auth)
.then((methods) => {
Expand Down Expand Up @@ -315,7 +315,7 @@ function accountExistsRedirectTenant(auth, samlProvider, googleProvider, goToApp
// The pending SAML credential.
pendingCred = error.credential;
// The provider account's email address.
const email = error.email;
const email = error.customData.email;
// Need to set the tenant ID again as the page was reloaded and the
// previous setting was reset.
auth.tenantId = tenantId;
Expand Down
6 changes: 3 additions & 3 deletions auth-next/oidc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function oidcSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down Expand Up @@ -58,7 +58,7 @@ function oidcSignInRedirectResult(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down Expand Up @@ -86,7 +86,7 @@ function oidcDirectSignIn(provider, oidcIdToken) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
4 changes: 2 additions & 2 deletions auth-next/saml.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function samlSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = SAMLAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down Expand Up @@ -58,7 +58,7 @@ function samlSignInRedirectResult(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = SAMLAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
4 changes: 2 additions & 2 deletions auth-next/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function twitterSignInPopup(provider) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = TwitterAuthProvider.credentialFromError(error);
// ...
Expand Down Expand Up @@ -65,7 +65,7 @@ function twitterSignInRedirectResult() {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = TwitterAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ reauthenticateWithPopup(auth.currentUser, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/apple/auth_apple_signin_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ getRedirectResult(auth)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = OAuthProvider.credentialFromError(error);

Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/facebook/auth_facebook_callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function checkLoginState(response) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ signInWithCredential(auth, credential)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/facebook/auth_facebook_signin_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ getRedirectResult(auth)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// AuthCredential type that was used.
const credential = FacebookAuthProvider.credentialFromError(error);
// ...
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/github/auth_github_signin_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GithubAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ getRedirectResult(auth)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GithubAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ signInWithCredential(auth, credential).catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/google-signin/auth_google_callback.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function onSignIn(googleUser) {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ signInWithCredential(auth, credential).catch((error) => {
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The credential that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ getRedirectResult(auth)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = GoogleAuthProvider.credentialFromError(error);
// ...
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/index/auth_signin_credential.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ signInWithCredential(auth, credential)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// ...
});
// [END auth_signin_credential_modular]
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ signInWithPopup(auth, samlProvider)
const pendingCred = error.credential;
// The credential's tenantId if needed: error.tenantId
// The provider account's email address.
const email = error.email;
const email = error.customData.email;
// Get sign-in methods for this email.
fetchSignInMethodsForEmail(email, auth)
.then((methods) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ getRedirectResult(auth).catch((error) => {
// The pending SAML credential.
pendingCred = error.credential;
// The provider account's email address.
const email = error.email;
const email = error.customData.email;
// Need to set the tenant ID again as the page was reloaded and the
// previous setting was reset.
auth.tenantId = tenantId;
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/oidc/auth_oidc_direct_sign_in.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ signInWithCredential(auth, credential)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/oidc/auth_oidc_signin_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ getRedirectResult(auth)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = OAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
2 changes: 1 addition & 1 deletion snippets/auth-next/saml/auth_saml_signin_popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ signInWithPopup(auth, provider)
const errorCode = error.code;
const errorMessage = error.message;
// The email of the user's account used.
const email = error.email;
const email = error.customData.email;
// The AuthCredential type that was used.
const credential = SAMLAuthProvider.credentialFromError(error);
// Handle / display error.
Expand Down
Loading