Join our community

Get access to the complete guide to developing and deploying fast, production-ready Nuxt apps.

7-15 Grant Access to the Course

In this lesson, we update our middleware to only allow access to the course if it’s been paid for.

We first create a hasAccess endpoint that looks for the CoursePurchase object. If it exists, the user is allowed access.

Then we update our route middleware and server middleware to use this new endpoint to control access.

In our route middleware, we also have to handle the case where the user logs in with Github but hasn’t purchased the course. Instead of letting them get into this weird state, we’ll immediately log them out instead.