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
  • 18,239
  • 30
  • 94
  • 161

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
  • 623,577
  • 216
  • 2,003
  • 1,567
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
  • 198,364
  • 44
  • 396
  • 360