0

What i am trying to do is allow users to create other accounts but the issue i ran into was when i create a user using createUserWithEmailAndPassword i automatically get signed in as the new user. so how do i avoid it.

I am trying to create user from admin panel where admin is registered. If i use the following code it login with new user data.

This is the code:

submit(){
    this.afAuth.createUserWithEmailAndPassword(this.form.Eemail, this.password).then( res => {
        this.form.userid = res.user.uid;
        this.user.addnotice(this.form);
        this.cancel();
        this.succesToast();
    }, err =>{
        this.failToast();
    })
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Silent
  • 39
  • 8
  • There is [solution](https://stackoverflow.com/a/38013551/10182897) for this already posting you just need to signout after the process successfully completed. – Ashish Jan 30 '21 at 11:12
  • @Ashish yea i did try that what happens is i get signed out completely even from the account i was previously signed in from – Silent Jan 30 '21 at 11:15
  • So you just want to make new user from admin panel ? Above question does not provide information about admin panel or any other. – Ashish Jan 30 '21 at 11:16
  • @Ashish yea exactly – Silent Jan 30 '21 at 11:17
  • the admin should be able to create new users so that's what i am trying to do but the thing is when i make the account i just get signed in to the newly created account – Silent Jan 30 '21 at 11:21
  • Please read my answer this might help you – Ashish Jan 30 '21 at 11:23
  • You have to use the admin SDK if you want to create users without getting signed in – emmanuel agarry Jan 30 '21 at 11:57
  • The linked answer shows how to use two `FirebaseApp` instances to accomplish the use-case, although the better approach is to use the Admin SDK in a trusted environment and call that from your application code as Ashish also said. – Frank van Puffelen Jan 30 '21 at 16:23

1 Answers1

2

There is no direct way provided for web development to create user without signin. Instead there is method to create user without sign-in in Admin-SDK which will solve your problem.

To access this function you have to use node.js in firebase function.

Ashish
  • 6,791
  • 3
  • 26
  • 48