question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CanActivateOr interface

See original GitHub issue

πŸš€ feature request

Relevant Package

This feature request is for @angular/router

Description

The current implementation of CanActivate interface is:

If all guards return true, navigation will continue.

Describe the solution you’d like

It would be useful to exist a CanActivateOr interface that will evaluate the following:

If some guards return true, navigation will continue.

Example

const routes: Routes = [
  {
    path: 'pathA',
    component: ComponentA,
    resolve: {
      data: ResolverA
    },
    CanActivateOr: [Guard1, Guard2] // If Guard1 OR Guard2 returns true then continue
  }
];

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
Airbladercommented, Dec 4, 2019

β€œand” is what the framework already does, but I agree that I’d KISS this and compose the guards instead.

1reaction
matthewjhcommented, Dec 4, 2019

It seems to me a better solution to write a new guard that composes your guards A and B, ORing their results, rather than lifting β€œor” to the framework. Should the framework later do the same for β€œand”?

Read more comments on GitHub >

github_iconTop Results From Across the Web

CanActivate - Angular
Interface that a class can implement to be a guard deciding if a route can be activated. If all guards return true ,...
Read more >
Angular CanActivate Guard Example - TekTutorialsHub
How to use CanActivate Guard ... First, we need to create a Angular Service. The service must import & implement the CanActivate Interface....
Read more >
Angular Basics: CanActivateβ€”Introduction to Routing Guards
Angular route guards are interfaces provided by Angular which, when implemented, allow us to control the accessibility of a route based onΒ ...
Read more >
Implementing Route Protection in Angular using CanActivate
This article will go through route protection in Angular and a step-by-step guide on implementing it using the CanActivate interface.
Read more >
Understanding Angular Guards - codeburst
To implementing route guard preventing access to the specific route we use CanActivate interface. ... Now here we have two options, first is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found