Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASL control on Angular Navigation #233

Closed
weilies opened this issue Nov 10, 2019 · 3 comments
Closed

CASL control on Angular Navigation #233

weilies opened this issue Nov 10, 2019 · 3 comments
Labels

Comments

@weilies
Copy link

weilies commented Nov 10, 2019

Let say i have a navigation links widget with many links

...
<a mat-list-item [routerLink]="'/leave_req'">Leave Request</a>
<a mat-list-item [routerLink]="'/leave_ops'">Leave Operation</a>
<a mat-list-item [routerLink]="'/leave_config'">Leave Config</a>
...

What's the working codes to
Leave Request - show to 'Employee', 'Operator' and 'Admin' role
Leave Operation - only show to 'Operator'
Leave Config - only show to 'Admin'
I am not keen for the show/hide logic to apply in my HTML because as user might simply guess the navigation to abuse the admin/operation screen. What's the better approach?

Thanks

@stalniy
Copy link
Owner

stalniy commented Nov 10, 2019

anyway you need to hide links first. Then read this https://medium.com/@sergiy.stotskiy/so-there-are-several-approaches-3ee962fb9fb5 . This is an answer for using casl with Vue router but you can use the similar logic for Angular router

@stalniy
Copy link
Owner

stalniy commented Nov 10, 2019

as far as I remember the router in Angular should have guards. You can create this guards to prevent user visiting some pages.

@stalniy
Copy link
Owner

stalniy commented Nov 13, 2019

Close as there is no action items from my side.

Thanks for using casl!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants