Adding role checks to client-side routes

Now that we have an easy way of determining whether the current user is in a specific role or not, we need to extend our route guard functionality to include role checking as well as authentication status. To make sure only logged in users are allowed to proceed the checkout, we added a meta property to the checkout page route definition, as well as a router hook that checks whether the user is authenticated before allowing them to access the page. We need to extend this functionality to support an additional meta property, which we can use to specify which user role is required to access a specific page.

Let's start by modifying the router's beforeEach hook to check for a meta.role property on the ...

Get ASP.NET Core 2 and Vue.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.