Skip to content

feature(router): Provide a way to coalesce multiple failed guards so only a single redirect is called #24618

Closed

Description

@jasonaden

When there are multiple guards they will run async. If only one of them performs a router.navigateByUrl(url), there shouldn't be a problem. However, sometimes there are multiple guards that will perform a redirect and there isn't a good way to determine which is the primary one and which one should run.

We need an API that either allows redirects to be scheduled with priority, then "flushed" using the highest priority one, or we need to cancel other guards when a guard performs a redirect. Another option would be to collect info from all the guards and let the redirect be configured in a single place.

This isn't a very well-defined feature as I think it will take some looking at the current APIs and how the navigation flow works to see what's feasible without introducing wildly breaking changes.

Activity

  1. self-assigned this
    on Jun 21, 2018
  2. added this to the Backlog milestone on Jun 21, 2018
  3. changed the title [-]feature(router): Provide a way to coalesce multiple failed guards so only a single redirect is called[/-] [+]GST-13 ⁃ feature(router): Provide a way to coalesce multiple failed guards so only a single redirect is called[/+] on Jul 19, 2018
  4. changed the title [-]GST-13 ⁃ feature(router): Provide a way to coalesce multiple failed guards so only a single redirect is called[/-] [+]feature(router): Provide a way to coalesce multiple failed guards so only a single redirect is called[/+] on Jul 26, 2018
  5. mohammedzamakhan commented on Dec 11, 2018

    @mohammedzamakhan

    Is there a documentation, on how to assign the highest priority redirect?

  6. jasonaden commented on Dec 11, 2018

    @jasonaden
    ContributorAuthor

    @mohammedzamakhan There's a good article by @nathan-lapinski coming out that describes the behavior (his Medium page can be found here).

    It looks like the best documentation we currently have on the prioritization is the tests for the prioritizedGuardValue operator: https://github.com/angular/angular/blob/master/packages/router/test/operators/prioritized_guard_value.spec.ts

  7. angular-automatic-lock-bot commented on Sep 14, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions