This episode is for members only

Sign up to access "Build An Uptime Monitor with Inertia" right now.

Get started
Already a member? Sign in to continue
Playing
29. Authorizing the endpoint details

Episodes

0%
Your progress
  • Total: 4h 59m
  • Played: 0m
  • Remaining: 4h 59m
Join or sign in to track your progress

Transcript

00:00
A really quick fix before we finish up on our endpoint index just here, this one, we didn't authorize this request. Now we know that over on our endpoint policy, we have the ability to update, destroy or check against this. We want to add one in here to say
00:18
can we view this or show this. So I'm going to go ahead and call this show, I think that makes sense, or list or whatever you want to call it. You could even create a generic touch to see if a user just has permission in general. So let's call this show and from the endpoint that we get passed in, of course the check is exactly the same here, we just want to make sure that the user has access
00:41
to this via the site that they own. So now that that's in there, we can go ahead and authorize this. Now of course you can authorize this directly within the controller, so we could say can we show this endpoint and that would work as normal. So we see that we've got permission to do this and if the id differs then it's not going to work. But again across our app we've been using
01:03
form requests, so I always like to keep things as consistent as possible and even if we're not posting through here, we can still create a form request to at least authorize this. So let's go ahead and do that now. Let's create out a form request here and keep the naming convention the same. If we look at the form request that we've got already, it's endpoint destroy controller,
01:22
endpoint store controller update. So we're gonna name this, if we just go ahead and make out a request here, endpoint and we could say endpoint index request. I think that actually makes a little bit more sense because technically this is an index, but then again we're showing this via root model binding. So yeah let's keep this to show, endpoint show controller request. I think
01:48
that makes a lot more sense. Okay so we can swap this out straight away. Endpoint show request and we're done. So we can go into here and the rules obviously we don't care about because we're just getting this, but from here we can do exactly the same thing. So this user can show this endpoint. So now everything is nicely tucked away in a form request. Our controller here is nice and clean.
02:12
I'll get rid of the eager loading note because we're going to come back to that later and there we go. So if we come over, sure enough it still works. So a quick fix up there. Of course that's really important because otherwise anyone would be able to type in any endpoint id and see information about that, which is not good.
44 episodes4 hrs 59 mins

Overview

Ready to dive into Inertia? Let's build a real-world app with Laravel, Inertia and Vue! If you're already working with Inertia, you'll pick up some tips and techniques for future projects.

This uptime monitor allows you to create and switch between sites, then add endpoints to monitor with frequency intervals. Using the power of scheduling and queues, it'll automatically alert the email addresses you've added via the UI when an endpoint goes down.

In this course, you'll learn to:

  • Build a real app from scratch with Inertia
  • Work with Laravel queues
  • Perform actions on models at user-defined intervals
  • Work with sub-minute schedules in Laravel
  • Send out channel notifications with Laravel
  • Use API resources to simplify Inertia data
  • Organise apps with events and observers
  • Create modals in Vue
  • Perform inline editing with Inertia forms
Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

No comments, yet. Be the first to leave a comment.