简体   繁体   English

使用 firebase 创建两种不同类型的用户身份验证

[英]Create two different kinds of users auth using firebase

Is it possible to create with firebase two different auth for two different user's roles?是否可以使用 firebase 为两个不同用户的角色创建两个不同的身份验证?

I'm building a website(using react and firebase) that is similar in its structure to Kahoot.我正在构建一个与 Kahoot 结构相似的网站(使用 react 和 firebase)。 As in Kahoot, I'm trying to create users that can create a quiz and users that can only play and answer the quiz.就像在 Kahoot 中一样,我正在尝试创建可以创建测验的用户和只能玩和回答测验的用户。 the users that create the quiz can log-in and answer a quiz but the users wich are signed as "players" cannot create a quiz and can only play.创建测验的用户可以登录并回答测验,但签名为“玩家”的用户不能创建测验,只能玩。

I've created two different auth pages and I don't know how to handle this situation using firebase, does someone have a solution?我创建了两个不同的身份验证页面,但我不知道如何使用 firebase 处理这种情况,有人有解决方案吗?

thx, Guy谢谢,伙计

During signup you can add add a variable in your Firebase Realtime Database for the user profile which identifies their role.在注册过程中,您可以在 Firebase 实时数据库中为标识其角色的用户配置文件添加一个变量。 Listen for the successful signup event and after that add the role value in database.侦听成功注册事件,然后在数据库中添加角色值。

After singup / signin you will read that variable and do your navigation accordingly.在注册/登录后,您将读取该变量并相应地进行导航。

If the user cannot change their role between quiz creator and quiz player after signup, then you can add a security rule on the user role property to stop update of this value by the users.如果用户在注册后无法在测验创建者和测验播放器之间更改其角色,那么您可以在用户角色属性上添加安全规则以阻止用户更新此值。

Security rules of Firebase: https://firebase.google.com/docs/database/security Firebase 安全规则: https ://firebase.google.com/docs/database/security

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

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