0π
β
A big thank-you to @RenaudTarnec. The data was returning null
and unfortunately the Auth provider doesnβt return any error when that happens.
By creating a log using the needed returned data before the fb.usersCollection.doc(account.userUid).set(account)
helped in figuring it out.
Bellow is the final working example.
import firebase from 'firebase'
import firebaseui from 'firebaseui'
const fb = require('@/services/firebaseInit')
export var uiConfig = {
signInSuccessUrl: '/dashboard',
signInFlow: 'popup',
callbacks: {
signInSuccessWithAuthResult: function(authResult) {
const newUser = authResult.user
const account = {
avatar : newUser.photoURL,
eMail : newUser.email,
userName : newUser.displayName,
userUid : newUser.uid,
accountHolder: []
}
console.log(
'New user: '+ account.userName + '\n' +
'with id: ' + account.userUid + '\n' +
'email: ' + account.eMail + '\n' +
'avatar: ' + account.avatar
)
fb.usersCollection.doc(account.userUid).set(account)
.then(() => {
console.log('New user account with ID:' + account.userUid + ' created');
})
.catch(err => {
console.log(err)
this.errorMsg = err.message
})
alert('Hello ' + account.userName + ', welcome to Firestore!');
return false;
}
},
signInOptions: [
firebase.auth.GoogleAuthProvider.PROVIDER_ID,
{
provider: firebase.auth.EmailAuthProvider.PROVIDER_ID,
requireDisplayName: true,
},
firebaseui.auth.AnonymousAuthProvider.PROVIDER_ID,
],
};
π€user742030
Source:stackexchange.com