繁体   English   中英

如何使用 reactjs 和 firebase 创建不同的用户

[英]how to create different users using reactjs and firebase

我正在尝试使用 ReactJs 和 firebase 创建 web 应用程序。 我想知道如何创建三个具有不同角色的用户,例如医生、患者、药剂师。

我的 Signup.js 文件

    if (pass.value != cpass.value) {
  alert("Password dont match")
}
else {
  try {
    var e = email.value
    const ref = db.collection("doctor")
    setLoading(true)
    await app
      .auth()
      .createUserWithEmailAndPassword(email.value, pass.value);
    ref.doc(e).set({
      "name": uname.value,
      "dob": dob.value,
      "email": email.value,
      "phno": phno.value,
      "regno": regno.value,
      "regyear": regyear.value,
      "gender": gender.value,
      "addr": addr.value,
      "pincode": pin.value,
      "city": city.value,
      "state": state.value,
      "bloodtype": bloodtype.value,
      "speciality": speciality.value,


    }).then(() => {
      console.log("Document successfully written!");
    });
    db.collection("users").doc(email.value).set({
      "email":email.value,
      "userType":"doctor"
    })

您已在以下代码段中将集合设置为医生:

const ref = db.collection("doctor")

如果您想将不同的用户添加到不同的 firebase 集合中,您只需替换集合名称:

const ref = db.collection("patient")

暂无
暂无

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

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