coder
coder

Reputation: 321

Multiple auth methods using AngularFire2

The AngularFire2 doc explains ways to set up login methods using password or federated methods such as Google or Facebook. But I want to set up password login together with federated methods as options. I tried the following without success:

const firebaseAuthConfig = {
  provider:[AuthProviders.Google, AuthProviders.Password],
  method: AuthMethods.Redirect
};

Is it possible to set up multiple auth methods using AngularFire2? Please advice with a simple piece of code.

Upvotes: 1

Views: 394

Answers (1)

cartant
cartant

Reputation: 58410

My understanding is that you can only setup a single authentication method via the module's initializeApp call. However, you can specify/override the authentication method when you make the login call.

There are examples further down the page in the document to which you have linked:

// Anonymous
af.auth.login({
  provider: AuthProviders.Anonymous,
  method: AuthMethods.Anonymous,
});

// Email and password
af.auth.login({
  email: '[email protected]',
  password: 'password',
},
{
  provider: AuthProviders.Password,
  method: AuthMethods.Password,
});

// Social provider redirect
af.auth.login({
  provider: AuthProviders.Twitter,
  method: AuthMethods.Redirect,
});

// Social provider popup
af.auth.login({
  provider: AuthProviders.Github,
  method: AuthMethods.Popup,
});

Upvotes: 1

Related Questions