JavaScript Only authenticate with Google Auth Provider if user exists

If you really want to use signInWithPopup method, you have this option, but it's not the best way. when you are signing in with google, signInWithPopup method returns a promise. you can access the isNewUser property in additionalUserInfo from resulting object. then delete the user you just created.

firebase.auth().signInWithPopup(provider).then(
     function (result) {
          var token = result.credential.accessToken;
          var user = result.user;

          //this is what you need
          var isNewUser = result.additionalUserInfo.isNewUser;
          if (isNewUser) {
               //delete the created user
               result.user.delete();
          } else {
               // your sign in flow
               console.log('user ' + user.email + ' does exist!');
          }
     }).catch(function (error) {
     // Handle Errors here.

});

This is the easy way but deleting after creating is not the best practice. There is an another option,

you can use, signInAndRetrieveDataWithCredential method for this. accoriding to the docs,

auth/user-not-found will be Thrown if signing in with a credential from firebase.auth.EmailAuthProvider#credential and there is no user corresponding to the given email.

function googleSignInWithCredentials(id_token) {
     // Build Firebase credential with the Google ID token.
     var credential = firebase.auth.GoogleAuthProvider.credential(id_token);

     // Sign in with credential from the Google user.

     firebase.auth().signInAndRetrieveDataWithCredential(credential)
          .then(function (userCredential) {
               //sign in
               console.log(userCredential.additionalUserInfo.username);
          }).catch(function (error) {
               // Handle Errors here.
               var errorCode = error.code;
               if (errorCode === 'auth/user-not-found') {
                    //handle this
               } else {
                    console.error(error);
               }
          });
}

here is an example from firebase github repo.

Answer:1

I am looping through elements using jQuery like this: $(".myelement").each(function() { $element = $(this).closest(".panel").attr("id"); console.log($element); }); This is working correctly and ...

I am looping through elements using jQuery like this: $(".myelement").each(function() { $element = $(this).closest(".panel").attr("id"); console.log($element); }); This is working correctly and ...

  1. create list from array
  2. create list from string python
  3. create list from dataframe
  4. create list from dictionary python
  5. create list from range python
  6. create list from text file python
  7. create list from column pandas
  8. create list from csv python
  9. create list from for loop python
  10. create list from 0 to n python
  11. create list from excel
  12. create list from template sharepoint
  13. create list from dictionary values python
  14. create list from string java
  15. create list from set
  16. create list from dictionary keys python
  17. create list from input python
  18. create list from excel column
  19. create list from column r
  20. create list from numpy array

I am getting problem to save my form data in the database. I am done small code on that which is shown below, when i enter data in form and click on my submit button it not work. $(".btn").click(...

I am getting problem to save my form data in the database. I am done small code on that which is shown below, when i enter data in form and click on my submit button it not work. $(".btn").click(...

  1. submit form using ajax
  2. submit form using javascript
  3. submit form using jquery
  4. submit form using anchor tag
  5. submit form using python
  6. submit form using javascript post method
  7. submit form using ajax javascript
  8. submit form using ajax in php example
  9. submit form using jquery ajax
  10. submit form using ajax in php
  11. submit form using ajax in laravel
  12. submit form using php
  13. submit form using button
  14. submit form using a tag
  15. submit form using ajax in wordpress
  16. submit form using react js
  17. submit form using jquery on button click
  18. submit form using angular 8
  19. submit form using angularjs
  20. submit form using curl php

Please help me to write a function to compute the square root of positive real numbers using the formula: x i+1 = (1/2) * (xi + (A / x1)), where 'A' - input real number. On the zero iteration next ...

Please help me to write a function to compute the square root of positive real numbers using the formula: x i+1 = (1/2) * (xi + (A / x1)), where 'A' - input real number. On the zero iteration next ...

  1. calculate square root by hand
  2. calculate square root in excel
  3. calculate square root of a number
  4. calculate square root in python
  5. calculate square root on iphone
  6. calculate square root of 2
  7. calculate square root on calculator
  8. calculate square root algorithm
  9. calculate square root in r
  10. calculate square root of 5
  11. calculate square root of 3
  12. calculate square root java
  13. calculate square root of matrix
  14. calculate square root curve
  15. calculate square root in c
  16. calculate square root of 2 by hand
  17. calculate square root without calculator
  18. calculate square root without sqrt
  19. calculate square root with exponents
  20. calculate square root of complex number

On my server side I have socket server listening and in my own laptop I have socket.io-client service and whenever I turn on both they are connecting. And when other people request to my server, ...

On my server side I have socket server listening and in my own laptop I have socket.io-client service and whenever I turn on both they are connecting. And when other people request to my server, ...

  1. error err_stream_write_after_end write after end
  2. error err_stream_write_after_end write after end node js
  3. error err_stream_write_after_end write after end express
  4. error err_stream_write_after_end write after en
  5. error err_stream_write_after_end write after end node
  6. error err_stream_write_after_end write after end createwritestream
  7. npm error err_stream_write_after_end write after end
  8. unhandledpromiserejectionwarning error err_stream_write_after_end write after end
  9. uncaught error err_stream_write_after_end write after end
  10. stack error err_stream_write_after_end write after end
  11. error code err_stream_write_after_end
  12. error code err_stream_write_after_end npm