I tried to use asynchronous code in the signInSuccessWithAuthResult of the Firebase UI in order to perform a conditional redirect but it always fails respectively my asynchronous code is not run and my redirect is ignored.
Are you able to use asynchronous code in signInSuccessWithAuthResult?
Or do I do something wrong?
const uiConfig = {
signInFlow: 'redirect',
signInSuccessUrl: appUrl,
signInOptions: signInOptions,
tosUrl: appUrl + '/terms',
privacyPolicyUrl: appUrl + '/privacy',
credentialHelper: firebaseui.auth.CredentialHelper.GOOGLE_YOLO,
autoUpgradeAnonymousUsers: true,
callbacks: {
signInSuccessWithAuthResult: async (_authResult, _redirectUrl) => {
await this.navigateRedirect();
return false;
},
signInFailure: this.onSignInFailure
}
};
private async navigateRedirect() {
const redirectUrl: string = await get<string>('deckdeckgo_redirect');
window.location.assign(redirectUrl);
}
I use firebaseui v4.0.0. and the above get used idb-keyval.
The signInSuccessWithAuthResult callback expects a synchronous function. Change to the following:
callbacks: {
signInSuccessWithAuthResult: (_authResult, _redirectUrl) => {
// This will run asynchronously. When it resolves, it will complete the
// redirect.
this.navigateRedirect();
// In the meantime, disable FirebaseUI redirect.
return false;
},
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With