I have a particular use case I need to satisfy. Can someone let me know if this can be easily achieved using Ionic 2 and Firebase 3?
Use Case: User logs in and is verified as a “Paid Subscriber”. Paid subscribers can build a team of email/password based app users. Team members can later log in and access limited functions of the app based on the role they were assigned.
Using Angularfire2, I was able to actually complete this use case, but with one unintended consequence.
Problem: When the Paid Subscriber creates a new Team Member (user) the Paid Subscriber is logged out, and the newly created user becomes the authorized user of the app.
After much research I discovered that this is actually the intended result when creating new users with Firebase 3 + AngularFire2.
After some research, there are two options:
Use the firebase-admin SDK to create an “admin version” of the app to create users. I can’t do this because there is not a version of the SDK (node.js and Java currently) I can use, and also because the the “admin” capability I’m trying to use needs to happen from a single app.
Create a second auth reference and use that auth to create new users. I currently can’t get this workaround to work within Ionic 2 + Angularfire2
Wouldn’t it be best to set up an invite system? I think the problem lies in trying to create a user on the fly, authentication is required. Is there a reason to create the user as opposed to sending an invite? You could also look into issuing a one-time-password.
Thanks! Yes, invites will definitely be implemented. I was going to eventually get to that, but I needed a way for “Team Members” to be added beforehand per the customer. The reasoning behind this is that the Team Leader can’t wait for a possible Team Member to be Authenticated and attached to the Team. In some cases, he’d need to build an entire team out, assign possible team members to a project tasks, and at a future date those members would create an account, login and see the projects they assigned to immediately.
I was able to work around it a bit by generating custom tokens for each team and keeping “Possible” team members in in an escrow new_members object. Based on some entered information, the app would recognize the new user, the team he belongs to and then build his team status accordingly. It’s working well for now.
@scottmotion : Do you have experience with Firebase’s invite system? Is there a way to package this “info in escrow” and send it with the invite. That way, when the user signs up it will do what my work around is doing?
I have the same problem and there doesn’t seem to be any solution except to change databases. I have been developing web apps for 25 years and have never heard of an action that allows an authenticated user create a new user and makes that newly created user the currently authenticated user…idiocracy.
Have been following all the strands to try and work out a solution especially for Angular2 and Ionic but there is nothing…so do I spend a few more days on “work arounds” or find something that just works.
Very disappointed in Firebase for not providing these action. Seems it just wants to address the simple blog/shopping site that demand you ‘leave your email address here’ before you leave. It’s not serious…oh well on to MongoDB…there’s a heap of platforms out there and life is too short. Best of luck with your solution!!
When I need to get this functionality going, I just add the new user’s data (email, name, etc) to the database, and have a database listener in Cloud Functions that creates the new user, the profile node in the database, sends a welcome email, etc.
Yeah…I have to agree with you…after looking around, I found the functionality from Firebase is too good to give up…so I used your method to re-instantiate the logged in user after creating a new one…works fine.
Thanks for the suggestion! I read a while back that I should look into Cloud Function for Firebase (I’d written it down in my notes, actually) but never got around to looking into it. Maybe it was you who mentioned it.
Would this negate the need to create new users from within the application? Does it require additional server setup/administration?
Is there a starter or example out there I could look into?
I’ve put off this project long enough because of this hang up…