0

I recently added google sign in with firebase to my website which already uses sign in with email and password. My website already has a lot of stuff involving their username (I have a separate database with email id and username, so I log them in using their email even if they give their username). So now, when a person signs in with google for the first time, it should save their google username and email in that database. How do I do this?

aravk33
  • 469
  • 2
  • 10
  • 18
  • A Google username and Email is the same. However I suppose you want to prompt your user to fill out a username associated only with your site correct? Then you need to create somekind of business logic that checks if the signed in users email or unique id corresponds to a username in your database. If it doesnt exist you simply prompt them for one. – Webbanditten Oct 11 '17 at 12:53
  • See https://stackoverflow.com/questions/43509021/how-to-add-username-with-email-and-password-in-firebase/43509186, https://stackoverflow.com/questions/42735452/firebase-store-user-variables or one of these: https://www.google.com/search?q=site%3Astackoverflow.com+firebase+store+user+name+javascript – Frank van Puffelen Oct 11 '17 at 13:39

1 Answers1

0

You can use the promisse return.

 let provider = new firebase.auth.GoogleAuthProvider();
 provider.addScope('https://www.googleapis.com/auth/plus.login');
 this.afAuth.auth.signInWithPopup(provider).then(user => console.log(user.email));

Or

this.afAuth.authState.take(1).subscribe(user => { console.log(user.email));
Fabio Campinho
  • 982
  • 8
  • 13