繁体   English   中英

如何使用 auth().createUserWithEmailAndPassword 接收用户名和国家/地区

[英]How to receive user name and country with auth().createUserWithEmailAndPassword

美好的一天开发者。 请我是本机反应的新手,我想对一个项目使用 firebase auth。 但我不知道如何使用正常的 auth().createUserWithEmailAndPassword 方法接受用户名和国家/地区。 到目前为止,以下是我的代码......但它确实工作正常。

 import React, {createContext, useState} from 'react'; import { StyleSheet, ActivityIndicator, View, Text, Alert } from 'react-native' import auth from '@react-native-firebase/auth'; import firebase from '@react-native-firebase/app'; export const AuthContext = createContext(); export const AuthProvider = ({children}) => { const [user, setUser] = useState(null); return ( <AuthContext.Provider value={{ user, setUser, login: async (email, password) => { try { await auth().signInWithEmailAndPassword(email, password); } catch (e) { console.log(e); Alert.alert( e.message); } }, register: async (name, email, password) => { try { await auth().createUserWithEmailAndPassword(email, password); firebase.auth().currentUser.updateProfile({ displayName: name }); Alert.alert("Success ✅", "Account created successfully") return {}; } catch (e) { Alert.alert( e.message ); } }, forgot: async (email) => { try { await firebase.auth().sendPasswordResetEmail(email); Alert.alert("Success ✅", "A Password Recorvery Link has been sent to your mail.") } catch (e) { Alert.alert( e.message ); } }, logout: async () => { try { await auth().signOut(); } catch (e) { Alert.alert( e.message ); } }, sendver: async () => { try { await firebase.auth().currentUser.sendEmailVerification(); } catch (e) { Alert.alert( e.message ); } }, }}> {children} </AuthContext.Provider> ); };

如果有人可以提供帮助,我会非常感谢。 非常感谢。

试试这个方法

firebase.auth().signInWithEmailAndPassword("abc@gmail.com", "******")
  .then(function(user) {
     // Success 
   })
.catch(function(error) {
    // Error Handling
});

注意:在数据库中保存成功的用户信息

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM