firebase.auth().getRedirectResult().then(function(result) { // NOTICE REDIRECT
if (result.credential) {
// This gives you a GitHub Access Token. You can use it to access the GitHub API.
var token = result.credential.accessToken;
// ...
}
// The signed-in user info.
var user = result.user;
}).catch(function(error) { // NOTICE CATCH
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// The email of the user's account used.
var email = error.email;
// The firebase.auth.AuthCredential type that was used.
var credential = error.credential;
// ...
});The catch(function(error)) behaves as expected: it's used to catch an "email already associated to another provider" error, for instance.
My problem/question is this: I need to display the error message in the UI to the user. But when I do it gets wiped out on the redirect (to the same UI view). I don't know how to stop the redirect, or otherwise retain and display the error message to the user.
Here's my code for displaying the error message (my modification to the catch in the boilerplate):
}).catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// Handling account-exists-with-different-credential
if (errorCode == 'auth/account-exists-with-different-credential') {
emailAddrMsg.textContent = errorMsg; // getElementById not shown
emailAddrMsg.removeAttribute('hidden'); // NOTICE REMOVE HIDDEN
return false;
}
});<p><input id="emailaddr" type="text" name="emailaddr" placeholder="email address" class="input-text"></p>
<p hidden id="emailaddr-msg" class="error-msg"></p>
This error display mechanism (hiding and showing) works fine when I do client-side error checking, but the involvement of the redirect api call to firebase messes with the ability to display the error message. Firebase does not provide any examples of display templates for errors.
Thanks for your help.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0bddd737-d39c-44f5-ad02-718e9dbcb716%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/0bddd737-d39c-44f5-ad02-718e9dbcb716%40googlegroups.com.
window.onload = function() {
console.log('window load');
initApp();
};
<form onsubmit="signIn(); return false;">