So I have this issue where every time I add a new user account, it kicks out the current user that is already signed in. I read the firebase api and it said that "If the new account was created, the user is signed in automatically" But they never said anything else about avoiding that.
//ADD EMPLOYEES
addEmployees: function(formData){
firebase.auth().createUserWithEmailAndPassword(formData.email, formData.password).then(function(data){
console.log(data);
});
},
I'm the admin and I'm adding accounts into my site. I would like it if I can add an account without being signed out and signed into the new account. Any way i can avoid this?
I faced the same problem, and I solved it with this way:
When the user login, I save the email and password in the shared preferences. And after creating the user, I login the user again with email and password that I have saved before.
Update 20161110 - original answer below
Also check out this answer for a different aproach.
Original answer
This is actually possible.
But not directly, the way to do it is to create a second auth reference and use that to create users:
If you don't specify wich firebase connection you use for an operation it will use the first one by default.
Source for multiple app references.
EDIT
For the actual creation of a new user it doesn't matter that there is nobody, or someone else then the admin, authenticated on the second auth reference because for creating an account all you need is the auth reference itself.
The following hasn't been tested but it is something to think about
The thing you do have to think about is writing data to firebase. Common practice is that users can edit/update their own user info so when you use the second auth reference for writing this should work. But if you have something like roles or permissions for that user make sure you write that with the auth reference that has the right permissions. In this case main auth is the admin and second auth is the newly created user.
I had a similar problem, so I asked the question in the Firebase Slack Community. I have implemented this, and it works like a charm.
If you are using Polymer and Firebase (polymerfire) see this answer: https://stackoverflow.com/a/46698801/1821603
Essentially you create a secondary
<firebase-app>
to handle the new user registration without affecting the current user.Update for Swift 4
I have tried a few different options to create multiple users from a single account, but this is by far the best and easiest solution.
Original answer by Nico
First Configure firebase in your AppDelegate.swift file
Add the following code to action where you are creating the accounts.
The Swift version: