Skip to content

[feat](emulators): add disableWarnings option #2750

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

Closed
wants to merge 1 commit into from
Closed
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
18 changes: 18 additions & 0 deletions docs/emulators/emulators.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,22 @@ import { SETTINGS as FIRESTORE_SETTINGS } from '@angular/fire/firestore';
export class AppModule { }
```

### 6.X.X Update

By default, when serving an app with an active auth emulator, a warning message is displayed in the browser.
This message can be disabled by providing an option with the auth emulator DI Token :

```ts
import { USE_EMULATOR as USE_AUTH_EMULATOR } from '@angular/fire/auth';

@NgModule({
// ... Existing configuration
providers: [
// ... Existing Providers
{ provide: USE_AUTH_EMULATOR, useValue: environment.useEmulators ? ['localhost', 9099, {disableWarnings: true}] : undefined },
]
})
export class AppModule { }
```

For older versions, please upgrade your app to latest version to get the advantages of these new features :rocket:
5 changes: 3 additions & 2 deletions src/auth/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ɵfetchInstance } from '@angular/fire';

export interface AngularFireAuth extends ɵPromiseProxy<firebase.auth.Auth> {}

type UseEmulatorArguments = [string, number];
type UseEmulatorArguments = [string, number, { disableWarnings: boolean }];
export const USE_EMULATOR = new InjectionToken<UseEmulatorArguments>('angularfire2.auth.use-emulator');

export const SETTINGS = new InjectionToken<firebase.auth.AuthSettings>('angularfire2.auth.settings');
Expand Down Expand Up @@ -89,7 +89,8 @@ export class AngularFireAuth {
const auth = zone.runOutsideAngular(() => app.auth());
if (useEmulator) {
// Firebase Auth doesn't conform to the useEmulator convention, let's smooth that over
auth.useEmulator(`http://${useEmulator.join(':')}`);
const [url, port, options] = useEmulator;
auth.useEmulator(`http://${url}:${port}`, options);
}
if (tenantId) {
auth.tenantId = tenantId;
Expand Down