Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 登录时在firebase中添加首次注册用户关系的更好方法是什么?_Javascript_Firebase_Authentication_Google Cloud Firestore - Fatal编程技术网

Javascript 登录时在firebase中添加首次注册用户关系的更好方法是什么?

Javascript 登录时在firebase中添加首次注册用户关系的更好方法是什么?,javascript,firebase,authentication,google-cloud-firestore,Javascript,Firebase,Authentication,Google Cloud Firestore,我正在制作一个教学应用程序,在这里我必须为师生建立一种关系。 教师是第一个登录该应用程序的人。现在我需要在教师集合中添加一个学生,而学生可以先注册或以任何方式注册。 例如,我计划给学生发送一个唯一的注册id, http://localhost:3000/signup?teacherId=1982828989当学生成功注册时,它将被添加到1982828989教师的学生集合中。 有没有更好的方法来做到这一点?或者firebase提供的任何其他开箱即用的方法?我喜欢您的解决方案,即通过链接识别登录前已

我正在制作一个教学应用程序,在这里我必须为师生建立一种关系。 教师是第一个登录该应用程序的人。现在我需要在教师集合中添加一个学生,而学生可以先注册或以任何方式注册。 例如,我计划给学生发送一个唯一的注册id,
http://localhost:3000/signup?teacherId=1982828989
当学生成功注册时,它将被添加到1982828989教师的学生集合中。
有没有更好的方法来做到这一点?或者firebase提供的任何其他开箱即用的方法?

我喜欢您的解决方案,即通过链接识别登录前已知的老师

我建议为每位教师创建组,并将用户分配到该组。 所以你可以改为发送组ID。如果将来发生变化,更改小组的教师姓名也会更容易。 这是扩展数据库的推荐解决方案。可能是这样的:

// An index to track Studen1 teachers
{
  "student": {
    "student-id-..": {
      "name": "Student Name",
      // Index of student teachers 
      "teachers": {
         // it can be also primary teachers
         "teacher-1-group-id-...": true,
         "teacher-2-group-id-...": true
      }
    },
    ...
  },
  "teachers": {
    "teacher-1-group-id-...": {
      "name": "Teacher Name",
      "members": {
        "student-id-1...": true,
        "student-id-2...": true,
        "student-id-3...": true
      }
    },
    ...
  }
}

如果您喜欢此解决方案,

这难道不会给出一些关于数据库结构的提示(安全方面)?给学生一个哈希版本的id不是更好吗?或者是一个从数据库中分离出来的代码?我对这种方法有点困惑,请您添加一些解释和示例,也许可以使用不同的方法?我会在登录屏幕上为学生添加一个教师列表,让他们选择要与之关联的教师。教师文档将有一个数据库ID,但他们只能看到他们的姓名/班级。这也是我的想法,但问题是我必须下载整个教师集合,这太多了。加上名称可以相同,会产生问题。也许你可以使用json web令牌?类似于此,但不是验证电子邮件地址,而是使用代码/链接注册学生。