0

I am wondering how I can set permissions on the URL that user is trying to access. I have already disabled buttons and other elements that may navigate him, based on permissions that I receive from backend, but I would also like to unable him to navigate to those pages by URL.

Thanks

uksz
  • 17,499
  • 30
  • 89
  • 153

2 Answers2

2

There are different ways:

where you redirect to the login route if not authenticated.

See also Check if the user logged in on any page change in Angular 2

Günter Zöchbauer
  • 558,509
  • 191
  • 1,911
  • 1,506
0

In addition to the Günter's answer, you could also try the following things:

  • Apply a directive to the routerLink to display / hide it based on permissions
  • Extend the Http class to check permissions globally before executing HTTP requests.

See this question for more details:

Community
  • 1
  • 1
Thierry Templier
  • 191,422
  • 38
  • 386
  • 349