如何在同一个 firebase 应用程序中处理两种类型的用户的单独登录? [英] How can handle separate login for two types of users in same firebase app?

查看:17
本文介绍了如何在同一个 firebase 应用程序中处理两种类型的用户的单独登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个场景并正在寻找解决方案.我正在开发一个应用程序并使用 Firebase 创建和验证用户.在我的应用程序中,基本上有两种类型的用户(1.User 和 2. Vender)和 User 可以在应用程序上登录,但 Vender 需要在 Web 面板上登录.我们正在使用 firebase 默认方法 (.createUser) 来创建用户并且它已经在工作.现在我也想在同一个应用程序中创建 Vender 配置文件,但 Vender 只能在 Web 应用程序上登录,而用户可以在移动应用程序上登录.

I have a scenario and looking solution for that. I am working on an application and Using Firebase to create and authenticate the User. In my app, basically two types of users (1.User & 2. Vender) and User can signIn on app but vender need to login on web panel. We are using firebase default method (.createUser) to create user and it's already working. Now I wants to create Vender profile too in same app but Vender can login only on web app and user can login on Mobile app.

有可能吗?如果是,那么请指导我这怎么可能?

Is it possible ? If yes then please guide me that how it's possible ?

提前致谢.

推荐答案

这是一个相当开放的问题,但我认为它归结为两件事:确定用户类型(供应商或用户)​​和检测他们是什么平台注册.

This is a fairly open-ended question but I think it comes down to two things: determining the user type (vendor or user) and detecting what platform they are signing up on.

两者都非常简单.

这是利用/users 节点来存储有关用户的附加信息的结构.来自存储用户数据

Heres's the structure which leverages a /users node to store additional info about the user. From Storing User Data

users
  uid_0
   name: "William:
   type: "vendor"
  uid_1
   name: "Leonard"
   type: "user"

然后当用户尝试登录时,应用会检查他们的用户身份验证,这将导致填充 authData.uid.

and then when the user attempts to log in, the app checks their user authentication, which will result with authData.uid being populated.

然后它会通过 authData.uid 查找用户并检查用户类型.如果是供应商,则向用户显示一条消息,告知他们必须通过 Web 门户登录,并且不要继续进入应用程序.

Then it would look up the user via authData.uid and check the user type. If it's a Vendor, display a message to the user that they must log in via the web portal, and don't proceed into the app.

还有 100 种其他方法可以处理此问题 - 为应用设置供应商节点和用户节点以进行身份​​验证,以防止他们在输入身份验证凭据之前选择供应商或用户.

There's a 100 other ways to handle this - setting up a Vendors Node and a Users node for the app to auth against to having them select Vendor Or User before entering their authentication credentials.

这篇关于如何在同一个 firebase 应用程序中处理两种类型的用户的单独登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆