如何在同一个Firebase应用程序中为两种类型的用户分别处理登录? [英] How can handle separate login for two types of users in same firebase app?
问题描述
我有一个方案,正在为此寻找解决方案.我正在开发一个应用程序,并使用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种其他处理方式-设置供应用程序进行身份验证的Vendors节点和Users节点,以使他们在输入身份验证凭据之前选择Vendor或User.
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屋!