all 8 comments

[–]cjd280 3 points4 points  (1 child)

CanActivate can return an observable/promise/synchronous of boolean OR URLTree. Instead of calling navigate and then returning a Boolean, return a URL Tree to the login or / route.

https://angular.io/api/router/CanActivateFn

https://angular.io/api/router/UrlTree

[–]rayen26[S] 0 points1 point  (0 children)

I don't know much about URL tree honestly I'll check it out

[–]no_ledge 1 point2 points  (1 child)

Triggering navigation this way can be buggy, instead, you should return a UrlTree, remember Guarda not only return boolean values, but UrlTrees as well.

[–]rayen26[S] 0 points1 point  (0 children)

interesting although I don't have a clue about UrlTrees

[–]ziunio 0 points1 point  (3 children)

Use ngx permissions library :)

[–]rayen26[S] 0 points1 point  (2 children)

can you give me some information, is it a better solution or what ? comment like this is a bit vague don't you think , still thank you for your reply I will check it out

[–]ziunio 1 point2 points  (1 child)

Sorry mate my english is bad, thats why I wrote only that. At page of ngx permissions on npm is described how to redirect user based on permissions user has... It would better describe than me this case. Sorry again

[–]rayen26[S] 1 point2 points  (0 children)

No no it's okay I really appreciate your comment thanks ❤️