This episode is for members only

Sign up to access "Build a Starter Kit With Inertia and Fortify" right now.

Get started
Already a member? Sign in to continue
Playing
13. Adding feature management checks

Episodes

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

Transcript

00:00
So in the next couple of episodes,
00:01
we're going to speak about feature management within Fortify. Now, we kind of touched on this earlier when we looked over in our Fortify config and just down the bottom here, we have this list of features.
00:13
Now, we can toggle these so we can, for example, get rid of the ability to register an account. And that's great. But at the moment, we're not reflecting this within our actual app.
00:25
So, for example, I can still go ahead and click create an account and we still see the modal. It's visible on the client side and we have this modal. Now, let's go ahead and just take a look
00:35
at what happens when I try and register an account with this disabled. And then we're going to do a little bit more source diving to figure out how this is all working and how we can get rid of all this stuff. So I'm going to go ahead and open up my console here, open up the network tab
00:49
and let's just try and register an account. It doesn't even matter if we enter any information in here, because when we click create an account, you can see we get a 404 not found.
00:58
So how is this working? Well, let's hop over to our Fortify roots file. So this is just on the vendor Laravel Fortify and root. And these are all of the routes that Laravel Fortify registers,
01:12
of course, that you can send data down to. Now, let's go and look for register. That's just at the top here under registration. And you can see, sure enough, we have this feature check here.
01:22
So we have this features object, which will open up in just a second. And that allows us to check if a specific feature is enabled. Now, in our case, if this is enabled, we get the view rendered, which we've decided to disable.
01:38
So we don't actually get this registered. But this is the route that we're trying to send that data down to, which, of course, is not working because we're not registering this route now. So this features object, if we just open this up,
01:50
allows us to from the config check if this feature is enabled. It's that simple. So we can actually use this functionality in our own routes to disable, in this case, the modal that we have created.
02:04
So I'm going to go ahead and just grab this line here and we'll go over to our own routes for our app. And obviously, this is our route for our modal, which we don't want to be available if we've disabled this feature. So we can just do exactly the same thing
02:18
as we get within the Fortify routes and just disable this. So I'm going to go ahead and pull the namespace in for features. And there we go. So now if we head over to our app, this page is no longer available.
02:33
And of course, the route is no longer available either. So we have got an error here, but we're going to tidy that up in the second episode because that takes a little bit more effort to get these features enabled and disabled on the client side.
02:47
So that's pretty much how this is working. So if we have any of these features disabled or enabled, Fortify itself takes care of disabling these on the back end. We've done that for our register page
03:00
and our route, and we're going to be doing these as we go. But we need to kind of speak about how to do this on the client side as well. So I've enabled this for now, but let's hop over to the next episode and look at how we disable these features specifically on the client side.
40 episodes5 hrs 21 mins

Overview

Let’s build our own Laravel starter kit with Inertia and include all the features you’d expect. We’ll implement authentication, email verification, profile photo uploads, two factor authentication, and more.

Fortify is a frontend agnostic authentication package for Laravel, meaning most of the work is done for us — we just need to build the frontend and make requests to the endpoints that Fortify registers.

Once you’re done, you’ll have a clean slate for building your next project, with the ability to control everything in your own starter kit.

Alex Garrett-Smith
Alex Garrett-Smith
Hey, I'm the founder of Codecourse!

Comments

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