【发布时间】:2023-04-07 17:57:01
【问题描述】:
/**
* @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'
};
}
我正试图找出一种方法来保存用户的电话号码,然后他们使用发短信给他们号码的代码进行确认。我在 github 上发布了这个问题,一位用户提到我可以使用 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. 这个 github 论坛的链接是 https://github.com/firebase/firebaseui-web/issues/383#issuecomment-387167882 我对如何做到这一点感到困惑。我需要保存确认的电话号码并将其显示在 html5 文件中。特别是我需要将它显示为 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
});
【问题讨论】:
标签: javascript firebase callback firebase-authentication firebaseui