Skip to content

Commit 2471f7d

Browse files
mukesh51davideast
authored andcommitted
docs(auth): Update 5. User authentication (angular#571)
Update the Authentication section to make it consistent with previous sections. Removed the ModuleId which would have caused errors, updated selector name, component name. Added logout() method for completion.
1 parent ea80969 commit 2471f7d

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

docs/5-user-authentication.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export class MyAppModule {}
4141
```ts
4242
import { bootstrap } from '@angular/platform-browser-dynamic';
4343
import { enableProdMode } from '@angular/core';
44-
import { <MyApp>Component, environment } from './app/';
44+
import { AppComponent, environment } from './app/';
4545
import {FIREBASE_PROVIDERS,
4646
defaultFirebase,
4747
AngularFire,
@@ -83,19 +83,24 @@ af.auth.login({ email: 'email', password: 'pass' });
8383
import { Component } from '@angular/core';
8484
import { AngularFire } from 'angularfire2';
8585

86-
@Component({
87-
moduleId: module.id,
88-
selector: 'app',
86+
@Component({
87+
selector: 'app-root',
8988
template: `
9089
<div> {{ (af.auth | async)?.uid }} </div>
9190
<button (click)="login()">Login</button>
91+
<button (click)="logout()">Logout</button>
9292
`,
9393
})
94-
export class RcTestAppComponent {
94+
export class AppComponent {
9595
constructor(public af: AngularFire) {}
96-
login() {
96+
97+
login() {
9798
this.af.auth.login();
9899
}
100+
101+
logout() {
102+
this.af.auth.logout();
103+
}
99104
}
100105
```
101106

@@ -148,20 +153,21 @@ af.auth.login({
148153

149154
**Example app:**
150155

156+
*Before running the below example, make sure you've correctly enabled the appropriate sign-in providers in your Firebase console under Auth tab to avoid any exceptions.*
157+
151158
```ts
152159
import { Component } from '@angular/core';
153160
import { AngularFire, AuthProviders, AuthMethods } from 'angularfire2';
154161

155162
@Component({
156-
moduleId: module.id,
157-
selector: 'app',
163+
selector: 'app-root',
158164
template: `
159165
<div> {{ (af.auth | async)?.uid }} </div>
160166
<button (click)="login()">Login With Twitter</button>
161167
<button (click)="overrideLogin()">Login Anonymously</button>
162168
`,
163169
})
164-
export class RcTestAppComponent {
170+
export class AppComponent {
165171
constructor(public af: AngularFire) {
166172
this.af.auth.subscribe(auth => console.log(auth));
167173
}

0 commit comments

Comments
 (0)