Skip to content

Commit

Permalink
examples/guards: [tweak] path blueprints
Browse files Browse the repository at this point in the history
  • Loading branch information
slovnicki committed May 22, 2021
1 parent 2165fd6 commit 92561ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions examples/guards/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ class MyApp extends StatelessWidget {
],
),
guards: [
// Guard /books/* by beaming to /login if the user is unauthenticated:
// Guard /books and /books/* by beaming to /login if the user is unauthenticated:
BeamGuard(
pathBlueprints: ['/books/*'],
pathBlueprints: ['/books', '/books/*'],
check: (context, location) =>
context.read<AuthenticationNotifier>().isAuthenticated,
beamToNamed: '/login',
Expand Down
8 changes: 4 additions & 4 deletions package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -492,9 +492,9 @@ You can define global guards (for example, authentication guard) or location gua
```dart
BeamerDelegate(
guards: [
// Guard /books/* by beaming to /login if the user is unauthenticated:
// Guard /books and /books/* by beaming to /login if the user is unauthenticated:
BeamGuard(
pathBlueprints: ['/books/*'],
pathBlueprints: ['/books', '/books/*'],
check: (context, location) => context.isAuthenticated,
beamToNamed: '/login',
),
Expand All @@ -511,8 +511,8 @@ BeamerDelegate(
List<BeamGuard> get guards => [
// Show forbiddenPage if the user tries to enter books/2:
BeamGuard(
pathBlueprints: ['/books/*'],
check: (context, location) => location.pathParameters['bookId'] != '2',
pathBlueprints: ['/books/2'],
check: (context, location) => false,
showPage: forbiddenPage,
),
];
Expand Down

0 comments on commit 92561ea

Please sign in to comment.