Skip to content

Commit 79185e7

Browse files
authored
Update route guards documentation examples to import pipes correctly (#3623)
Fixes the route guards documentation by using the correct `AuthGuard` import instead of `AngularFireAuthGuard`.
1 parent 3f7fe29 commit 79185e7

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

site/src/auth/route-guards.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,20 @@ eleventyNavigation:
77

88
## Route users with AngularFire guards
99

10-
`AngularFireAuthGuard` provides a prebuilt [`canActivate` Router Guard](https://angular.io/api/router/CanActivate) using `AngularFireAuth`. By default unauthenticated users are not permitted to navigate to protected routes:
10+
`AuthGuard` provides a prebuilt [`canActivate` Router Guard](https://angular.io/api/router/CanActivate) using `AngularFireAuth`. By default unauthenticated users are not permitted to navigate to protected routes:
1111

1212
```ts
13-
import { AngularFireAuthGuard } from '@angular/fire/auth-guard';
13+
import { AuthGuard } from '@angular/fire/auth-guard';
1414

1515
export const routes: Routes = [
1616
{ path: '', component: AppComponent },
17-
{ path: 'items', component: ItemListComponent, canActivate: [AngularFireAuthGuard] },
17+
{ path: 'items', component: ItemListComponent, canActivate: [AuthGuard] },
1818
]
1919
```
2020

2121
## Customizing the behavior
2222

23-
To customize the behavior of `AngularFireAuthGuard`, you can pass an RXJS pipe through the route data's `authGuardPipe` key.
23+
To customize the behavior of `AuthGuard`, you can pass an RXJS pipe through the route data's `authGuardPipe` key.
2424

2525
The `auth-guard` module provides the following pre-built pipes:
2626

@@ -36,7 +36,7 @@ The `auth-guard` module provides the following pre-built pipes:
3636
Example use:
3737

3838
```ts
39-
import { AngularFireAuthGuard, hasCustomClaim, redirectUnauthorizedTo, redirectLoggedInTo } from '@angular/fire/auth-guard';
39+
import { AuthGuard, hasCustomClaim, redirectUnauthorizedTo, redirectLoggedInTo } from '@angular/fire/auth-guard';
4040

4141
const adminOnly = () => hasCustomClaim('admin');
4242
const redirectUnauthorizedToLogin = () => redirectUnauthorizedTo(['login']);
@@ -45,10 +45,10 @@ const belongsToAccount = (next) => hasCustomClaim(`account-${next.params.id}`);
4545

4646
export const routes: Routes = [
4747
{ path: '', component: AppComponent },
48-
{ path: 'login', component: LoginComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectLoggedInToItems }},
49-
{ path: 'items', component: ItemListComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},
50-
{ path: 'admin', component: AdminComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: adminOnly }},
51-
{ path: 'accounts/:id', component: AdminComponent, canActivate: [AngularFireAuthGuard], data: { authGuardPipe: belongsToAccount }}
48+
{ path: 'login', component: LoginComponent, canActivate: [AuthGuard], data: { authGuardPipe: redirectLoggedInToItems }},
49+
{ path: 'items', component: ItemListComponent, canActivate: [AuthGuard], data: { authGuardPipe: redirectUnauthorizedToLogin }},
50+
{ path: 'admin', component: AdminComponent, canActivate: [AuthGuard], data: { authGuardPipe: adminOnly }},
51+
{ path: 'accounts/:id', component: AdminComponent, canActivate: [AuthGuard], data: { authGuardPipe: belongsToAccount }}
5252
];
5353
```
5454

@@ -68,7 +68,7 @@ export const routes: Routes = [
6868

6969
## Compose your own pipes
7070

71-
`AngularFireAuthGuard` pipes are RXJS operators which transform an optional User to a boolean or Array (for redirects). You can easily build your own to customize behavior further:
71+
`AuthGuard` pipes are RXJS operators which transform an optional User to a boolean or Array (for redirects). You can easily build your own to customize behavior further:
7272

7373
```ts
7474
import { map } from 'rxjs/operators';
@@ -92,7 +92,7 @@ const editorOnly = () => pipe(customClaims, map(claims => claims.role === 'edito
9292

9393
## Using router state
9494

95-
`AngularFireAuthGuard` will also accept `AuthPipeGenerator`s which generate `AuthPipe`s given the router state:
95+
`AuthGuard` will also accept `AuthPipeGenerator`s which generate `AuthPipe`s given the router state:
9696

9797
```ts
9898
import { pipe } from 'rxjs';

0 commit comments

Comments
 (0)