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 ?
Thanks in advance.
Firebase account linking allows users to sign into the same account using different authentication providers. By linking the user's Facebook and Twitter credentials, for example, the user can sign into the same account using either sign-in provider.
To detect if a user is already logged in Firebase with JavaScript, we can call the onAuthStateChanged method. firebase. auth(). onAuthStateChanged((user) => { if (user) { // ... } else { // ... } });
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.
Both are pretty easy.
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"
and then when the user attempts to log in, the app checks their user authentication, which will result with authData.uid being populated.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With