You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/api-reference.md
+123-4Lines changed: 123 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -121,17 +121,22 @@ bootstrap(App, [
121
121
]);
122
122
```
123
123
124
-
### FirebaseAuth
124
+
### AngularFireAuth
125
125
126
-
Injectable service for managing authentication state.
126
+
Type: `class`
127
+
128
+
Injectable service for managing authentication state. Extends rxjs `ReplaySubject`, which represents an object that is both an observable sequence as well as an observer.
127
129
128
130
#### Logging In
129
131
To log in a user, call the `login` method on an instance of `FirebaseAuth` class. The method has
The signature that is used depends on which AuthMethod you chose to use to login.
@@ -189,6 +194,61 @@ export class MyApp {
189
194
}
190
195
```
191
196
197
+
The AuthConfiguration Object has the following signature
198
+
199
+
```ts
200
+
exportinterfaceAuthConfiguration {
201
+
method?:AuthMethods;
202
+
provider?:AuthProviders;
203
+
remember?:string;
204
+
scope?:string[];
205
+
}
206
+
```
207
+
208
+
* The AuthMethods and AuthProviders are enums, defining values for Methods and Providers respectively.
209
+
See [Facebook-Login](https://firebase.google.com/docs/auth/web/facebook-login) and [Google-Signin](https://firebase.google.com/docs/auth/web/google-signin) for more information.
Takes one of the three arguments as input. The `EmailPasswordCredentials` object is same, as mentioned in createUser method. The login method can also take a [firebase.auth.AuthCredential](https://firebase.google.com/docs/reference/js/firebase.auth.AuthCredential) object as mentioned here.
`getAuth(): FirebaseAuthState` : Returns the client's current Authentication State. The FirebaseAuthState is an interface with following signature
291
+
292
+
```ts
293
+
exportinterfaceFirebaseAuthState {
294
+
uid: string;
295
+
provider: AuthProviders;
296
+
auth: firebase.User;
297
+
expires?:number;
298
+
github?:firebase.UserInfo;
299
+
google?:firebase.UserInfo;
300
+
twitter?:firebase.UserInfo;
301
+
facebook?:firebase.UserInfo;
302
+
anonymous?:boolean;
303
+
}
304
+
```
305
+
306
+
Sample Usage:
307
+
308
+
```ts
309
+
constructor(publicauth: FirebaseAuth) {
310
+
this.authState=auth.getAuth();
311
+
auth.subscribe((state: FirebaseAuthState) => {
312
+
this.authState=state;
313
+
});
314
+
}
315
+
316
+
getauthenticated(): boolean {
317
+
return this.authState !== null;
318
+
}
319
+
```
320
+
321
+
`logout(): void`: Deletes the authentication token issued by Firebase and signs user out. See [Auth.signOut()](https://firebase.google.com/docs/reference/js/firebase.auth.Auth#signOut) for more information.
322
+
323
+
*It is worth noting that logout() is an asynchronous operation. There is an open bug against the Firebase SDK to make this return a promise.*
324
+
325
+
Sample Usage:
326
+
327
+
```ts
328
+
signOut(): {
329
+
this.af.auth.logout();
330
+
}
331
+
```
332
+
333
+
`createUser(credentials: EmailPasswordCredentials): firebase.Promise<FirebaseAuthState>` : Creates a new user with email/password provided. Returns a promise filled with FirebaseAuthState, which contains the uid of the created user.
334
+
335
+
The credentials object is an object containing email and password of the user to be created. See [createUserWithEmailAndPassword](https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword) for more information.
0 commit comments