in sample/authui-react/src/components/app.tsx [161:234]
public startSignIn(auth: Auth): Promise<UserCredential> {
return new Promise((resolve, reject) => {
this.signIn(
!!auth.tenantId,
() => {
this.updateError(null);
signInWithRedirect(auth, new (SAMLAuthProvider as any)(SAML_PROVIDER_ID))
.catch((error: any) => {
this.updateError(error);
});
return false;
},
() => {
this.updateError(null);
signInWithRedirect(auth, new GoogleAuthProvider())
.catch((error: any) => {
this.updateError(error);
});
return false;
},
() => {
this.updateError(null);
signInWithRedirect(auth, new FacebookAuthProvider())
.catch((error: any) => {
this.updateError(error);
});
return false;
},
(email: string) => {
this.updateError(null);
fetchSignInMethodsForEmail(auth, email)
.then((signInMethods: string[]) => {
if (signInMethods.length) {
// Show password sign in.
this.signInWithEmail(
email,
(password: string) => {
this.updateError(null);
signInWithEmailAndPassword(auth, email, password)
.then((userCredential: any) => {
resolve(userCredential);
})
.catch((error: any) => {
this.updateError(error);
});
return false;
});
} else {
// Show password sign up.
this.signUpWithEmail(
email,
(displayName: string, password: string) => {
this.updateError(null);
createUserWithEmailAndPassword(auth, email, password)
.then((userCredential: any) => {
return userCredential.user.updateProfile({displayName})
.then(() => {
resolve(userCredential);
});
})
.catch((error: any) => {
this.updateError(error);
});
return false;
});
}
})
.catch((error: any) => {
this.updateError(error);
});
return false;
});
});
}