Firebase को फोननंबर से बने अकाउंट को कैसे लिंक करें
To मैं उपयोगकर्ता को मोबाइल नंबर का उपयोग करके verifyPhoneNumber
और अपडेट के साथ अपनी प्रोफ़ाइल को अपडेट करने देता हूंcurrentUser.updatePhoneNumber
And मेरी समस्या तब आती है जब मैं फोन द्वारा लॉगिन की अनुमति देता हूं, और एक नया उपयोगकर्ता फोन नंबर के साथ साइन इन करने की कोशिश करता है, एक खाता स्वचालित रूप से बनाया जाता है।
अगर मुझे ईमेल नंबर के साथ नंबर जोड़ने की आवश्यकता है , तो उपरोक्त विधि credential-already-in-use
त्रुटि वापस कर देगी ।
फायरबेस अपने प्रलेखन में निम्नलिखित विधि की सिफारिश करता है ।
var credential = firebase.auth.PhoneAuthProvider.credential(confirmationResult.verificationId, code);
firebase.auth().signInWithCredential(credential);
इसलिए मैंने यह एक साथ किया linkWithCredential
, लेकिन साइन इन करेंव्रेडेंशियल के साथ एक परिणाम देता हैresult.credential = null
// Sign in user with the account you want to link to
auth.signInWithCredential(credential).then(function(result) {
console.log("Sign In Success", result);
var currentUser = result.user;
return prevUser.linkWithCredential(result.credential) //this line doesn't work.
.then(function(linkResult) {
return auth.signInWithCredential(linkResult.credential);
})
}).catch(function(error) {
console.log("Sign In Error", error);
});
Result.credential = null के बाद से, मैं LinkWithCredential के साथ आगे बढ़ने में असमर्थ हूं।
मैंने भी कोशिश की है linkWithPhoneNumber
, लेकिन यह एक सत्यापन आईडी देता है, जिसे मैं अभी भी खाता मर्ज नहीं कर सकता।
Knowमैं जानता हूं कि आप लोगों ने फोननंबर खाते को अन्य खाते (फेसबुक / गूगल / ईमेल) के साथ कैसे मिला दिया?
जवाब
यदि आप किसी मौजूदा खाते को किसी फ़ोन नंबर से लिंक करना चाहते हैं जिसका आप उपयोग कर सकते हैं linkWithPhoneNumber
। मूल रूप से आप उपयोगकर्ता के साइन इन करने के बाद (Google के साथ कहते हैं), आप उपयोगकर्ता की जानकारी प्राप्त करते हैं और फिर बाद में उस नंबर को फोन नंबर के साथ लिंक करते हैं। मुझे एक विस्तृत उत्तर मिला जो आपके प्रश्न लिंक के समान है
शायद कुछ पसंद है
const confirmationResult = await firebase.auth().currentUser.linkWithPhoneNumber(phoneNumber, recaptcha);
//Prompt your user for the code they recieved via sms here
confirmationResult.confirm(code);
जहां आपके पास उपयोगकर्ता है जो उपयोगकर्ता नाम / पासवर्ड, फेसबुक गूगल, आदि के माध्यम से लॉग इन किया है ... काम करेगा?
चूंकि आपको फोन लिंकिंग से एक सत्यापन आईडी नहीं मिलती है, बल्कि एक पुष्टिकरण