使用@react native firebase/auth合并多个帐户
在Firebase中,我将“每个电子邮件地址一个帐户”设置为true。使用@react native firebase/auth合并多个帐户,firebase,react-native,firebase-authentication,react-native-firebase,Firebase,React Native,Firebase Authentication,React Native Firebase,在Firebase中,我将“每个电子邮件地址一个帐户”设置为true。 这意味着,当用户已经使用Google登录创建了Firebase帐户……然后他们尝试并同时注册Facebook(相同的电子邮件地址),那么我会通过error.code===“auth/account使用不同的凭据存在”捕获错误或者,如果他们尝试使用电子邮件/密码进行注册,我会使用err.code.toString()===='auth/email已在使用' 现在我只是提醒他们,并告诉他们一个帐户已经存在与该电子邮件…但我想把帐
这意味着,当用户已经使用Google登录创建了Firebase帐户……然后他们尝试并同时注册Facebook(相同的电子邮件地址),那么我会通过
error.code===“auth/account使用不同的凭据存在”
捕获错误或者,如果他们尝试使用电子邮件/密码进行注册,我会使用
err.code.toString()===='auth/email已在使用'
现在我只是提醒他们,并告诉他们一个帐户已经存在与该电子邮件…但我想把帐户链接在一起,而不是。
关于如何做到这一点,在线上有太多相互冲突的信息……而且链接帐户似乎不适用于@react native firebase下面的代码……一旦发现错误,我想知道可以使用什么代码链接帐户
import auth from '@react-native-firebase/auth';
export const signUpUserWithEmail = (email, password) => {
auth()
.createUserWithEmailAndPassword(email, password)
.then(user => {
console.log(User created in firebase);
})
.catch(err => {
if (err.code.toString() === 'auth/email-already-in-use') {
Alert.alert(
'Email already registered',
'You have already created an account using that email. You have used either Google, Facebook, or email/password as credentials',
);
}
export const _facebookSignin = async () => {
try {
// Attempt login with permissions
const result = await LoginManager.logInWithPermissions([
'public_profile',
'email',
]);
const data = await AccessToken.getCurrentAccessToken();
const firebaseCredential = await auth.FacebookAuthProvider.credential(
data.accessToken,
);
const fbUserObj = await auth().signInWithCredential(firebaseCredential);
} catch (error) {
if (error.code === 'auth/account-exists-with-different-credential') {
Alert.alert(
'Email already registered',
'You have already created an account using that email. You have used either Google, Facebook, or email/password as credentials',
);
你找到解决这个问题的方法了吗?我还没有-将在Codementor上寻找帮助。一旦我得到解决方案,我会告诉你你找到解决方案了吗?我没有-将在Codementor上寻找帮助。一旦我得到解决方案,我就会发帖