0

so I have lets say 2 routes '/admin-route' and '/superuser-route' and both require 'admin' and 'superuser' privileges respectively to access these routes.

When user clicks on this route I check privileges and if they're false for that user I activate a '/no-access' route guard.

The challenge is that I have breadcrumbs in my app and if the user gets a no-access state I want to display in the breadcrumbs which route he previously accessed.

So if user tries to access '/admin-route' and he doesn't have admin rights the no-access route guard kicks in and I want to have displayed in the breadcrumbs 'Admin' and the same if user tries to access '/superuser-route' and gets no-access page I want 'Superuser' breadcrumb.

I'm having a challenging time figuring out how to tell the route guard which was the previous route to be able to display the correct breadcrumb.

I hope this isn't too confusing and any help is appreciated!

Adi
  • 9
  • 7

1 Answers1

0

have a logic in route guard or a central service.

with every valid route update the value of that property.

when user moves on to invalid route , use the value of the property.

like instance of navigation end, -- update the property with check like as per your logic

LogicBlower
  • 1,250
  • 1
  • 8
  • 14