Reputation: 23
/**
* @return {!Object} The FirebaseUI config.
*/
function getUiConfig() {
return {
'callbacks': {
// Called when the user has been successfully signed in.
'signInSuccess': function(user, credential, redirectUrl) {
// You can also access this via
//document.cookie = (firebase.auth().currentUser.phoneNumbe)
//setCookie('phoneNumber', firebase.auth().currentUser.phoneNumber);
handleSignedInUser(user);
// Do not redirect.
//'signInSuccessUrl': "http://localhost:8080/CurrentLocation.html",
return true;
}
},
// Opens IDP Providers sign-in flow in a popup.
'signInSuccessUrl': "http://localhost:1357/Carrier/homepage_latest.html",
'signInFlow': 'popup',
'signInOptions': [
// The Provider you need for your app. We need the Phone Auth
//firebase.auth.TwitterAuthProvider.PROVIDER_ID,
{
provider: firebase.auth.PhoneAuthProvider.PROVIDER_ID,
recaptchaParameters: {
type: 'image', // another option is 'audio'
size: 'invisible', // other options are 'normal' or 'compact'
badge: 'bottomleft' // 'bottomright' or 'inline' applies to invisible.
}
}
],
// Terms of service url.
'tosUrl': 'https://www.google.com'
};
}
I'm trying to figure out a way to save the user's phone number after they confirm it with a code that is texted to their number. I posted this question on github and a user mentioned that i can use a signInSuccesWithAuthResult callback. In the ui config, you can provide a signInSuccesWithAuthResult and save the phone number to cookie in the callback. You can access the phone number by doing authResult.user.phoneNumber.
The link to this github forum is https://github.com/firebase/firebaseui-web/issues/383#issuecomment-387167882 I'm confused on how to do this. I need to save the confirmed phone number and display it in a html5 file. Specially I need to display it as a marker label for a google maps API pin.
var data = snapshot.val();
var markerLabel =
var marker = new google.maps.Marker({
position: {
lat: data.User.l[0],
lng: data.User.l[1]
},
map: map,
label: markerLabel
});
Upvotes: 0
Views: 415
Reputation: 785
From the html/js file you'd like to display the phone number, you should still be able to access the same firebase Auth instance via firebase.auth()
. And from there, the phone number is available via firebase.auth().currentUser.phoneNumber
as long as the user is signed in on it.
Upvotes: 1