Skip to content

fix getAuth for non browser entry points #4519

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages-exp/auth-exp/index.cordova.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* just use index.ts
*/

import { FirebaseApp } from '@firebase/app-exp';
import { FirebaseApp, _getProvider } from '@firebase/app-exp';
import { Auth } from './src/model/public_types';
import { indexedDBLocalPersistence } from './src/platform_browser/persistence/indexed_db';

Expand All @@ -49,6 +49,12 @@ export {
import { cordovaPopupRedirectResolver } from './src/platform_cordova/popup_redirect/popup_redirect';

export function getAuth(app: FirebaseApp): Auth {
const provider = _getProvider(app, 'auth-exp');

if (provider.isInitialized()) {
return provider.getImmediate();
}

return initializeAuth(app, {
persistence: indexedDBLocalPersistence,
popupRedirectResolver: cordovaPopupRedirectResolver
Expand Down
8 changes: 7 additions & 1 deletion packages-exp/auth-exp/index.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import * as fetchImpl from 'node-fetch';

import { FirebaseApp } from '@firebase/app-exp';
import { FirebaseApp, _getProvider } from '@firebase/app-exp';
import { Auth } from './src/model/public_types';

import { initializeAuth } from './src';
Expand All @@ -43,6 +43,12 @@ FetchProvider.initialize(
export * from './src';

export function getAuth(app: FirebaseApp): Auth {
const provider = _getProvider(app, 'auth-exp');

if (provider.isInitialized()) {
return provider.getImmediate();
}

return initializeAuth(app);
}

Expand Down
8 changes: 7 additions & 1 deletion packages-exp/auth-exp/index.rn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

import { AsyncStorage } from 'react-native';

import { FirebaseApp } from '@firebase/app-exp';
import { FirebaseApp, _getProvider } from '@firebase/app-exp';
import { Auth } from './src/model/public_types';

import { initializeAuth } from './src';
Expand All @@ -40,6 +40,12 @@ export const reactNativeLocalPersistence = getReactNativePersistence(
);

export function getAuth(app: FirebaseApp): Auth {
const provider = _getProvider(app, 'auth-exp');

if (provider.isInitialized()) {
return provider.getImmediate();
}

return initializeAuth(app, {
persistence: reactNativeLocalPersistence
});
Expand Down